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

#include <type_traits>

#include "list/list.h"

namespace tav {
namespace runtime {

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

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

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

}
}

#endif  // TYPEASVALUE_SRC_RUNTIME_LIST_FOR_EACH_H_