aboutsummaryrefslogtreecommitdiff
path: root/src/list/operation/take.h
blob: effba33f04680b7a4fb5ccf7f87b9a94ffcba7e0 (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
#ifndef TYPEASVALUE_SRC_LIST_OPERATION_TAKE_H_
#define TYPEASVALUE_SRC_LIST_OPERATION_TAKE_H_

#include "operation/math.h"

namespace tav {

namespace detail {

template <
	typename Count,
	typename Current
>
struct Take {
	typedef Cons<
		Head<Current>,
		Eval<Take<
			Substract<Count, Size<1>>,
			Tail<Current>
		>>
	> type;
};

template <typename Current>
struct Take<Size<0>, Current> {
	typedef void type;
};

template <typename Count>
struct Take<Count, void> {
	typedef void type;
};

template <>
struct Take<Size<0>, void> {
	typedef void type;
};

}

template <
	typename Count,
	typename Current
>
using Take = Eval<detail::Take<Count, Current>>;

}

#endif  // TYPEASVALUE_SRC_LIST_OPERATION_TAKE_H_