aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/list/list.h8
-rw-r--r--src/type.h3
-rw-r--r--test.cc18
3 files changed, 29 insertions, 0 deletions
diff --git a/src/list/list.h b/src/list/list.h
index c03a0ef..66394fc 100644
--- a/src/list/list.h
+++ b/src/list/list.h
@@ -21,6 +21,14 @@ struct List<Head> {
typedef Cons<Head, void> type;
};
+template <
+ typename Type,
+ Type... Values
+>
+using ListOfType = List<
+ std::integral_constant<Type, Values>...
+>;
+
template <typename Cons>
using Head = Car<Cons>;
diff --git a/src/type.h b/src/type.h
index 76a1aae..9fc30e2 100644
--- a/src/type.h
+++ b/src/type.h
@@ -14,6 +14,9 @@ using Size = std::integral_constant<std::size_t, Value>;
template <bool Value>
using Boolean = std::integral_constant<bool, Value>;
+template <char Value>
+using Char = std::integral_constant<char, Value>;
+
template <
typename X,
typename Y
diff --git a/test.cc b/test.cc
index 33d0248..cf99e8e 100644
--- a/test.cc
+++ b/test.cc
@@ -239,6 +239,24 @@ static_assert(
"(list 1 2) != (cons 1 (cons 2 void))"
);
+// list of type
+
+static_assert(
+ std::is_same<
+ tav::Cons<tav::Int<1>, void>,
+ tav::ListOfType<int, 1>::type
+ >::value,
+ "(list 1) != (cons 1 void)"
+);
+
+static_assert(
+ std::is_same<
+ tav::Cons<tav::Int<1>, tav::Cons<tav::Int<2>, void>>,
+ tav::ListOfType<int, 1, 2>::type
+ >::value,
+ "(list 1 2) != (cons 1 (cons 2 void))"
+);
+
// list length
static_assert(