3 #include "utilities/tuple_like.h" 5 #include <initializer_list> 11 template <
typename Func,
typename... Ts>
12 constexpr
auto apply_params(Func&& func, Ts&&... ts) {
13 return func(std::forward<Ts>(ts)...);
16 template <
typename Func,
typename T,
size_t... Ix>
17 constexpr
auto apply(Func&& func, T&& t, std::index_sequence<Ix...>) {
18 return apply_params(std::forward<Func>(func),
19 tuple_like_getter<Ix>(std::forward<T>(t))...);
24 template <
typename Callback,
typename Collection>
25 constexpr
auto apply(Callback&& callback, Collection&& c) {
26 return apply(std::forward<Callback>(callback),
27 std::forward<Collection>(c),
28 std::make_index_sequence<
29 tuple_like_size_v<decay_const_ref_t<Collection>>>{});
34 template <
typename Callbacks,
typename Collection,
size_t... Ix>
35 constexpr
auto apply_each(Callbacks&& callbacks,
37 std::index_sequence<Ix...>) {
38 return std::make_tuple(apply(tuple_like_getter<Ix>(callbacks), c)...);
46 template <
typename Callbacks,
typename Collection>
47 constexpr
auto apply_each(Callbacks&& callbacks,
const Collection& c) {
49 std::forward<Callbacks>(callbacks),
51 std::make_index_sequence<
52 tuple_like_size_v<decay_const_ref_t<Callbacks>>>{});
55 template <
typename Callbacks,
size_t... Ix>
56 constexpr
auto apply_each(Callbacks&& callbacks, std::index_sequence<Ix...>) {
57 return std::make_tuple(tuple_like_getter<Ix>(callbacks)()...);
60 template <
typename Callbacks>
61 constexpr
auto apply_each(Callbacks&& callbacks) {
63 std::forward<Callbacks>(callbacks),
64 std::make_index_sequence<
65 tuple_like_size_v<decay_const_ref_t<Callbacks>>>{});
70 template <
typename Callbacks,
typename Collection,
size_t... Ix>
71 void call_each(Callbacks&& callbacks,
73 std::index_sequence<Ix...>) {
74 (void)std::initializer_list<int>{
75 ((void)apply(tuple_like_getter<Ix>(callbacks), c), 0)...};
82 template <
typename Callbacks,
typename Collection>
83 void call_each(Callbacks&& callbacks,
const Collection& c) {
84 call_each(std::forward<Callbacks>(callbacks),
86 std::make_index_sequence<
87 tuple_like_size_v<decay_const_ref_t<Callbacks>>>{});
90 template <
typename Callbacks,
size_t... Ix>
91 void call_each(Callbacks&& callbacks, std::index_sequence<Ix...>) {
92 (void)std::initializer_list<int>{
93 ((void)tuple_like_getter<Ix>(callbacks)(), 0)...};
96 template <
typename Callbacks>
97 void call_each(Callbacks&& callbacks) {
98 call_each(std::forward<Callbacks>(callbacks),
99 std::make_index_sequence<
100 tuple_like_size_v<decay_const_ref_t<Callbacks>>>{});
Definition: allocator.h:6