aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/list/for_each.h
blob: b7496a840e4d0bd66036a8440d9dd5aab0e50b67 (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
#ifndef TYPEASVALUE_SRC_RUNTIME_LIST_FOR_EACH_H_
#define TYPEASVALUE_SRC_RUNTIME_LIST_FOR_EACH_H_

#include <type_traits>

#include "sfinae.h"
#include "list/list.h"

namespace tav {
namespace runtime {

template <
	typename Current,
	typename Function,
	detail::enable_if<std::is_void<Current>::value> = 0
>
void for_each(const Function&) { }

template <
	typename Current,
	typename Function,
	detail::enable_if<!std::is_void<Current>::value> = 0
>
void for_each(const Function& function) {
	function(Head<Current>::value);

	for_each<Tail<Current>, Function>(function);
}

}
}

#endif  // TYPEASVALUE_SRC_RUNTIME_LIST_FOR_EACH_H_