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