aboutsummaryrefslogtreecommitdiff
path: root/src/list/operation/take.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/list/operation/take.h')
-rw-r--r--src/list/operation/take.h40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/list/operation/take.h b/src/list/operation/take.h
new file mode 100644
index 0000000..db25640
--- /dev/null
+++ b/src/list/operation/take.h
@@ -0,0 +1,40 @@
+#ifndef TYPEASVALUE_SRC_LIST_OPERATION_TAKE_H_
+#define TYPEASVALUE_SRC_LIST_OPERATION_TAKE_H_
+
+#include "operation/math.h"
+
+namespace tav {
+
+template <
+ typename Count,
+ typename Current
+>
+struct Take {
+ typedef Cons<
+ Head<Current>,
+ typename Take<
+ Substract<Count, Size<1>>,
+ Tail<Current>
+ >::type
+ > type;
+};
+
+template <typename Current>
+struct Take<Size<0>, Current> {
+ typedef void type;
+};
+
+template <typename Count>
+struct Take<Count, void> {
+ typedef void type;
+};
+
+template <>
+struct Take<Size<0>, void> {
+ typedef void type;
+};
+
+
+}
+
+#endif // TYPEASVALUE_SRC_LIST_OPERATION_TAKE_H_