From 5f98c3eb62f3085a69f8df36de663bb7c6107341 Mon Sep 17 00:00:00 2001
From: Adrian Kummerlaender
Date: Thu, 29 Jan 2015 19:13:39 +0100
Subject: Added `ListOfType` list constructor alias * enables construction of
`Cons` structures using the same value type across all their elements
---
src/list/list.h | 8 ++++++++
src/type.h | 3 +++
test.cc | 18 ++++++++++++++++++
3 files changed, 29 insertions(+)
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
{
typedef Cons type;
};
+template <
+ typename Type,
+ Type... Values
+>
+using ListOfType = List<
+ std::integral_constant...
+>;
+
template
using Head = Car;
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;
template
using Boolean = std::integral_constant;
+template
+using Char = std::integral_constant;
+
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, void>,
+ tav::ListOfType::type
+ >::value,
+ "(list 1) != (cons 1 void)"
+);
+
+static_assert(
+ std::is_same<
+ tav::Cons, tav::Cons, void>>,
+ tav::ListOfType::type
+ >::value,
+ "(list 1 2) != (cons 1 (cons 2 void))"
+);
+
// list length
static_assert(
--
cgit v1.2.3