aboutsummaryrefslogtreecommitdiff
path: root/src/list/list.h
blob: c9e6a9e34a1f70e41be1936d58b189e91d35915a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#ifndef TYPEASVALUE_SRC_LIST_LIST_H_
#define TYPEASVALUE_SRC_LIST_LIST_H_

#include "cons.h"

namespace tav {

namespace detail {

template <
	typename    Head,
	typename... Tail
>
struct List {
	typedef Eval<Cons<
		Head,
		Eval<List<Tail...>>
	>> type;
};

template <typename Head>
struct List<Head> {
	typedef Eval<Cons<Head, void>> type;
};

template <typename Head>
struct List<Head, void> {
	typedef Eval<List<Head>> type;
};

template <typename... Tail>
struct List<void, Tail...> {
	typedef Eval<List<Tail...>> type;
};

template <>
struct List<void, void> {
	typedef void type;
};

}

template <typename... Elements>
using List = Eval<detail::List<Elements...>>;

template <
	typename Type,
	Type...  Values
>
using ListOfType = List<
	std::integral_constant<Type, Values>...
>;

template <typename Cons>
using Head = Car<Cons>;

template <typename Cons>
using Tail = Cdr<Cons>;

}

#include "operation/basic.h"
#include "operation/nth.h"
#include "operation/take.h"
#include "operation/drop.h"
#include "operation/append.h"
#include "operation/concatenate.h"

#endif  // TYPEASVALUE_SRC_LIST_LIST_H_