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

#include "conditional/if.h"

namespace tav {

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

template <
	template<typename> class Predicate
>
struct TakeWhile<Predicate, void> {
	typedef void type;
};

}

#endif  // TYPEASVALUE_SRC_LIST_OPERATION_HIGHER_TAKE_WHILE_H_