13 #include <type_traits>
29 template<
class... first_pack_t,
class... second_pack_t>
30 struct join<std::tuple<first_pack_t...>, std::tuple<second_pack_t...>>
32 using type = std::tuple<first_pack_t..., second_pack_t...>;
35 template<
class... first_pack_t,
class second_t,
class... optional_args_t>
36 struct join<std::tuple<first_pack_t...>, second_t, optional_args_t...>
38 using type = std::tuple<first_pack_t..., second_t, optional_args_t...>;
41 template<
class... args_t>
42 using join_t =
typename join<args_t...>::type;
54 template<
class target_t,
class... pack_t>
57 using type = std::tuple<pack_t...>;
60 template<
class target_t,
class parameter_t,
class... pack_t>
63 using type =
typename join<
64 std::conditional_t<std::is_same_v<target_t, parameter_t>, std::tuple<>, std::tuple<parameter_t>>,
65 typename remove_single<target_t, std::tuple<pack_t...>>::type>::type;
79 template<
class... types_t>
80 struct remove<std::tuple<types_t...>, std::tuple<>>
82 using type = std::tuple<types_t...>;
85 template<
class target_t,
class... remaining_targets_t,
class... types_t>
86 struct remove<std::tuple<types_t...>, std::tuple<target_t, remaining_targets_t...>>
90 typename remove<std::tuple<types_t...>, std::tuple<remaining_targets_t...>>::type>::type;
93 template<
class... args_t>
94 using remove_t =
typename remove<args_t...>::type;
101 template<
class T,
class tuple_t>
109 template<
class T,
class U,
class... args_t>
114 template<
class T,
class... args_t>
115 struct contains<T, std::tuple<T, args_t...>> : std::true_type
127 template<
class tuple_t,
class T>
128 using contains = details::contains<T, tuple_t>;
130 template<
class tuple_t,
class T>
141 template<
class tuple_t,
template<
class T>
class transformation_t>
144 template<
template<
class T>
class transformation_t,
class... args_t>
145 struct transform<std::tuple<args_t...>, transformation_t>
147 using type = std::tuple<typename transformation_t<args_t>::type...>;
150 template<
class tuple_t,
template<
class T>
class transformation_t>
161 template<
class tuple_t,
class T>
164 template<
class T,
class... args_t>
165 struct index<std::tuple<T, args_t...>, T>
167 static constexpr
size_t value = 0;
170 template<
class T,
class U,
class... args_t>
171 struct index<std::tuple<U, args_t...>, T>
173 static constexpr
size_t value = 1 +
index<std::tuple<args_t...>, T>::value;
176 template<
class tuple_t,
class T>
196 template<
class tuple_t,
class type_callable_t>
197 constexpr
void iterate(
const type_callable_t& callable)
200 using tuple_pointer_type = transform_t<tuple_t, std::add_pointer>;
202 auto temp_callable = [&callable]<
class T>(const T&)
204 callable.template operator()<std::remove_pointer_t<T>, index_v<tuple_pointer_type, T>>();
208 [&temp_callable](
auto&&... args)
210 ((temp_callable(args)), ...);
212 tuple_pointer_type());
219 constexpr
size_t pow(
size_t n1,
size_t n2)
222 for (
size_t i = 0; i < n2; ++i)
228 template<
class... tuples_t>
231 template<
class... args_t>
234 using type = std::tuple<args_t...>;
237 template<
class... args_1_t,
class... args_2_t,
class... args_rest_t>
238 struct merge_tuples<std::tuple<args_1_t...>, std::tuple<args_2_t...>, args_rest_t...>
240 using type =
typename merge_tuples<std::tuple<args_1_t..., args_2_t...>, args_rest_t...>::type;
243 template<
class inner_tuples_tuple_t,
class... all_types_t>
246 template<
class... inner_tuples_t,
class... all_types_t>
250 template<
class inner_tuple_t>
253 using type = std::tuple<typename tuple::join<inner_tuple_t, all_types_t>::type...>;
260 template<
class all_tuples_t,
class prev_new_tuples_t,
size_t nCombinations,
class... all_types_t>
263 template<
bool bBreak ,
class all_tuples_t,
class new_tuples_t,
size_t nCombinations,
class... all_types_t>
266 using type = all_tuples_t;
269 template<
class all_tuples_t,
class new_tuples_t,
size_t nCombinations,
class... all_types_t>
276 template<
class all_tuples_t,
class prev_new_tuples_t,
size_t nCombinations,
class... all_types_t>
279 using new_tuples_t =
typename generate_layer<prev_new_tuples_t, all_types_t...>::type;
282 nCombinations == std::tuple_size_v<all_tuples_t>,
286 all_types_t...>::type;
303 template<
class... all_types_t>
306 static constexpr
size_t nTypes =
sizeof...(all_types_t);
307 static constexpr
size_t nCombinations = nTypes * (details::pow(nTypes, nTypes) - 1) / (nTypes - 1);
308 using start_tuples_t = std::tuple<std::tuple<all_types_t>...>;
309 using type =
typename details::combine<start_tuples_t, start_tuples_t, nCombinations, all_types_t...>::type;
312 template<
class... all_types_t>
313 using permutations_t =
typename permutations<all_types_t...>::type;
void iterate(const container_t &container, const callable_t &callable, const filter_t &filter=filters::always_true, const adapter_t &adapter=iterate_adapters::no_change)
Iterate container with filter.
double pow(T number, int nPower)
Power function for integer power.
Check that tuple type contains T.
Get an index of the first occurrence of the given type.
Appends types or another tuple to tuple.
Generates k-permutations with repetition for all_types_t.
Removes all types from the second argument from the first tuple.