OSSIA
Open Scenario System for Interactive Application
Loading...
Searching...
No Matches
for_each.hpp
1#pragma once
2
3namespace ossia
4{
26// Invokes the functor with every type
27
28template <typename T>
29struct type_tag
30{
31 using type = T;
32};
33
34template <template <typename...> typename T, typename... Args, typename F>
35constexpr void for_each(T<Args...>, F f)
36{
37 (f.template operator()<Args>(), ...);
38}
39
40template <template <typename...> typename T, typename... Args, typename F>
41constexpr void for_each_tagged(T<Args...>, F f)
42{
43 (f(type_tag<Args>{}), ...);
44}
45
46template <typename... Args, typename F>
47constexpr void for_each_type(F f)
48{
49 (f.template operator()<Args>(), ...);
50}
51
52template <template <typename...> typename T, typename... Args, typename F>
53constexpr void for_each_type(T<Args...>, F f)
54{
55 (f.template operator()<Args>(), ...);
56}
57
58template <typename... Args, typename F>
59constexpr void for_each_type_tagged(F f)
60{
61 (f(type_tag<Args>{}), ...);
62}
63
64// Invokes the functor with every type, this code generation is done at compile
65// time
66template <typename... Args, typename F>
67constexpr void for_each_type_if(F&& f)
68{
69 (f.template operator()<Args>() || ...);
70}
71
72template <typename... Args, typename F>
73constexpr void for_each_type_if_tagged(F&& f)
74{
75 (f(type_tag<Args>{}) || ...);
76}
77}
Definition git_info.h:7