aboutsummaryrefslogtreecommitdiff
path: root/src/list/operation/higher/filter.h
blob: 8788aedcb56ed3a0588ddd2d0edc8abccc8026cd (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
#ifndef TYPEASVALUE_SRC_LIST_OPERATION_HIGHER_FILTER_H_
#define TYPEASVALUE_SRC_LIST_OPERATION_HIGHER_FILTER_H_

#include "fold.h"
#include "conditional/if.h"

namespace tav {

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;

};

}

#endif  // TYPEASVALUE_SRC_LIST_OPERATION_HIGHER_FILTER_H_