From 01029e59e8eda0a160291c3c92f9db5b1cac54d3 Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Fri, 16 Jan 2015 22:08:09 +0100 Subject: Implemented basic `Cons` value type and `List` constructor * `Cons` is a straigth forward type _pair_ containing `car` and `cdr` typedefs ** they may be accessed using `Car` and `Cdr` helper template aliases ** there is no enforcement of _Cons_ structure and type equality whatsoever *** i.e. similar to Scheme and different from how it is implemented in _ConstList_ * `List` is a recursive variadic helper template for constructing `Cons` value types ** simplifies _Cons_ construction and may be expanded to offer type deduction and built upon to enforce type equality * added appropriate test cases --- src/list/list.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/list/list.h (limited to 'src/list/list.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::type + > type; +}; + +template +struct List { + typedef Cons type; +}; + +} + +#endif // TYPEASVALUE_SRC_LIST_LIST_H_ -- cgit v1.2.3