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
70
71
72
73
|
#ifndef TYPEASVALUE_SRC_LIST_OPERATION_HIGHER_MISC_H_
#define TYPEASVALUE_SRC_LIST_OPERATION_HIGHER_MISC_H_
#include "fold.h"
#include "list/operation/concatenate.h"
#include "conditional/if.h"
namespace tav {
template <
template<typename> class Function,
typename List
>
class Map {
private:
template <
typename Current,
typename Previous
>
struct function_wrapper {
typedef Cons<Function<Current>, Previous> type;
};
public:
typedef typename Fold<function_wrapper, void, List>::type type;
};
template <
template<typename> class Function,
typename List
>
class Filter {
private:
template <
typename Current,
typename Previous
>
struct function_wrapper {
typedef If<
Function<Current>::type::value,
Cons<Current, Previous>,
Previous
> type;
};
public:
typedef typename Fold<function_wrapper, void, List>::type type;
};
template <typename List>
class Reverse {
private:
template <
typename Current,
typename Previous
>
struct reversed_concatenate {
typedef typename Concatenate<
Previous,
Cons<Current, void>
>::type type;
};
public:
typedef typename Fold<reversed_concatenate, void, List>::type type;
};
}
#endif // TYPEASVALUE_SRC_LIST_OPERATION_HIGHER_MISC_H_
|