aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/list/for_each.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/runtime/list/for_each.h')
-rw-r--r--src/runtime/list/for_each.h32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/runtime/list/for_each.h b/src/runtime/list/for_each.h
new file mode 100644
index 0000000..74f038f
--- /dev/null
+++ b/src/runtime/list/for_each.h
@@ -0,0 +1,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
+>
+constexpr void for_each(const Function&) { }
+
+template <
+ typename Current,
+ typename Function,
+ typename std::enable_if<!std::is_void<Current>::value, std::size_t>::type = 0
+>
+constexpr void for_each(const Function& function) {
+ function(Head<Current>::value);
+
+ for_each<Tail<Current>, Function>(function);
+}
+
+}
+}
+
+#endif // TYPEASVALUE_SRC_RUNTIME_LIST_FOR_EACH_H_