aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/list/cons.h23
-rw-r--r--src/list/list.h26
2 files changed, 49 insertions, 0 deletions
diff --git a/src/list/cons.h b/src/list/cons.h
new file mode 100644
index 0000000..b858c4c
--- /dev/null
+++ b/src/list/cons.h
@@ -0,0 +1,23 @@
+#ifndef TYPEASVALUE_SRC_LIST_CONS_H_
+#define TYPEASVALUE_SRC_LIST_CONS_H_
+
+namespace tav {
+
+template <
+ typename CAR,
+ typename CDR
+>
+struct Cons {
+ typedef CAR car;
+ typedef CDR cdr;
+};
+
+template <typename Cons>
+using Car = typename Cons::car;
+
+template <typename Cons>
+using Cdr = typename Cons::cdr;
+
+}
+
+#endif // TYPEASVALUE_SRC_LIST_CONS_H_
diff --git a/src/list/list.h b/src/list/list.h
new file mode 100644
index 0000000..47d0d2f
--- /dev/null
+++ b/src/list/list.h
@@ -0,0 +1,26 @@
+#ifndef TYPEASVALUE_SRC_LIST_LIST_H_
+#define TYPEASVALUE_SRC_LIST_LIST_H_
+
+#include "cons.h"
+
+namespace tav {
+
+template <
+ typename Head,
+ typename... Tail
+>
+struct List {
+ typedef Cons<
+ Head,
+ typename List<Tail...>::type
+ > type;
+};
+
+template <typename Head>
+struct List<Head> {
+ typedef Cons<Head, void> type;
+};
+
+}
+
+#endif // TYPEASVALUE_SRC_LIST_LIST_H_