aboutsummaryrefslogtreecommitdiff
path: root/src/list/operation/higher/find.h
blob: bf9d04ffdbdcf1fef285c7d0b31d9c47e0cc0041 (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
#ifndef TYPEASVALUE_SRC_LIST_OPERATION_HIGHER_FIND_H_
#define TYPEASVALUE_SRC_LIST_OPERATION_HIGHER_FIND_H_

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

namespace tav {

template <
	template<typename> class Predicate,
	typename                 Current
>
struct Find {
	typedef typename If<
		Predicate<Head<Current>>::type::value,
		Head<Current>,
		typename Find<Predicate, Tail<Current>>::type
	>::type type;
};

template <
	template<typename> class Predicate
>
struct Find<Predicate, void> {
	typedef Boolean<false> type;
};

}

#endif  // TYPEASVALUE_SRC_LIST_OPERATION_HIGHER_FIND_H_