aboutsummaryrefslogtreecommitdiff
path: root/src/list
diff options
context:
space:
mode:
Diffstat (limited to 'src/list')
-rw-r--r--src/list/operation/basic.h35
1 files changed, 34 insertions, 1 deletions
diff --git a/src/list/operation/basic.h b/src/list/operation/basic.h
index cee4cbc..dbd080e 100644
--- a/src/list/operation/basic.h
+++ b/src/list/operation/basic.h
@@ -2,6 +2,7 @@
#define TYPEASVALUE_SRC_LIST_OPERATION_BASIC_H_
#include "operation/math.h"
+#include "conditional/if.h"
namespace tav {
@@ -26,7 +27,10 @@ struct Nth {
typedef If<
equal_value<Index, Size<0>>::value,
Head<Cons>,
- typename Nth<Substract<Index, Size<1>>, Tail<Cons>>::type
+ typename Nth<
+ Substract<Index, Size<1>>,
+ Tail<Cons>
+ >::type
> type;
};
@@ -35,6 +39,35 @@ struct Nth<Index, void> {
typedef void type;
};
+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_BASIC_H_