aboutsummaryrefslogtreecommitdiff
path: root/src/list/generator/iota.h
blob: 73b7cc85ace65788363e3d284aed6b21cad76950 (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
#ifndef TYPEASVALUE_SRC_LIST_GENERATOR_IOTA_H_
#define TYPEASVALUE_SRC_LIST_GENERATOR_IOTA_H_

#include "operation/math.h"

namespace tav {

namespace detail {

template <
	typename Count,
	typename Initial,
	typename Step
>
struct Iota {
	typedef Cons<
		Initial,
		Eval<Iota<
			Substract<Count, Size<1>>,
			Add<Initial, Step>,
			Step
		>>
	> type;
};

template <
	typename Initial,
	typename Step
>
struct Iota<Size<1>, Initial, Step> {
	typedef Cons<Initial, void> type;
};

}

template <
	typename Count,
	typename Initial,
	typename Step
>
using Iota = Eval<detail::Iota<Count, Initial, Step>>;

}

#endif  // TYPEASVALUE_SRC_LIST_GENERATOR_IOTA_H_