12 template<
typename Pred,
typename Type>
15 template<
typename Pred,
typename... Types>
16 struct AllHelper<Pred, List<Types...>> : Constexpr<(meta::Invoke<Pred, Types> {} && ...)> {};
19template<concepts::TypeList List, concepts::MetaInvocable Pred>
20constexpr inline bool All = detail::AllHelper<Pred, List>::value;
23 template<
typename R,
typename List>
26 template<
typename R,
typename... Types>
30template<
typename R, concepts::TypeList T>
35 struct AsListHelper {};
37 template<
auto... values>
38 struct AsListHelper<
ListV<values...>> :
TypeConstant<List<Constexpr<values>...>> {};
40 template<
template<
typename...>
typename Template,
typename... Types>
41 struct AsListHelper<Template<Types...>> :
TypeConstant<List<Types...>> {};
43 template<
typename R,
typename... Args>
44 struct AsListHelper<R(Args...)> :
TypeConstant<List<Args...>> {};
51 template<
template<
typename...>
typename Template,
typename List>
52 struct AsTemplateHelper {};
54 template<
template<
typename...>
typename Template,
typename... Types>
56 struct AsTemplateHelper<Template,
List<Types...>> :
TypeConstant<Template<Types...>> {};
62template<concepts::TypeList T>
67 struct ConcatHelper {};
69 template<
typename... Ts,
typename... Us,
typename... Rest>
70 struct ConcatHelper<
List<Ts...>,
List<Us...>, Rest...> : ConcatHelper<List<Ts..., Us...>, Rest...> {};
82template<concepts::TypeList L,
typename T>
85template<concepts::TypeList L,
typename T>
88template<concepts::TypeList List>
95 template<
typename T,
typename... Rest>
99template<concepts::TypeList L>
106 template<
typename T,
typename U,
typename... Rest>
107 struct PopBackHelper<
List<T, U, Rest...>> :
TypeConstant<PushFront<Type<PopBackHelper<List<U, Rest...>>>, T>> {};
110template<concepts::TypeList L>
114 template<
typename List,
typename Acc,
typename MetaFn>
115 struct FoldHelper {};
117 template<
typename Acc,
typename MetaFn>
120 template<
typename T,
typename... Rest,
typename Acc,
typename MetaFn>
121 struct FoldHelper<
List<T, Rest...>, Acc, MetaFn>
122 :
TypeConstant<Type<FoldHelper<List<Rest...>, Invoke<MetaFn, Acc, T>, MetaFn>>> {};
125template<concepts::TypeList List,
typename Init, concepts::MetaInvocable MetaFn>
129 template<
typename List,
typename Init,
typename MetaFn>
130 struct FoldRightHelper {};
132 template<
typename Init,
typename MetaFn>
135 template<
typename T,
typename... Rest,
typename Init,
typename MetaFn>
136 struct FoldRightHelper<
List<T, Rest...>, Init, MetaFn>
137 :
TypeConstant<Invoke<MetaFn, Type<FoldRightHelper<List<Rest...>, Init, MetaFn>>, T>> {};
140template<concepts::TypeList List,
typename Init, concepts::MetaInvocable MetaFn>
144 template<
typename Pred>
145 struct FilterReducer {
146 template<
typename Acc,
typename Val>
151template<concepts::TypeList List, concepts::MetaInvocable Pred>
155 template<
typename Needle,
typename Replacement>
156 struct ReplaceReducer {
157 template<
typename Acc,
typename Val>
162template<concepts::TypeList List,
typename Needle,
typename Replacement>
166 template<
typename Pred,
typename Replacement>
167 struct ReplaceIfReducer {
168 template<
typename Acc,
typename Val>
173template<concepts::TypeList List, concepts::MetaInvocable Pred,
typename Replacement>
177 template<
typename...>
178 struct TransformHelper {};
180 template<
typename... Types,
typename Fun>
182 struct TransformHelper<
List<Types...>, Fun> :
TypeConstant<List<Invoke<Fun, Types>...>> {};
185template<concepts::TypeList List,
typename Function>
186using Transform = detail::TransformHelper<List, Function>::Type;
189 struct PushBackIfUnique {
190 template<concepts::TypeList Lst,
typename T>
193 template<concepts::TypeList Lst,
typename T>
197 template<concepts::TypeList Lst,
typename T>
202template<concepts::TypeList Lst>
206 template<
typename T,
typename U>
209 template<
typename T,
typename U,
typename... Ts,
typename... Us>
210 struct ZipHelper<
List<T, Ts...>,
List<U, Us...>>
211 :
TypeConstant<Concat<List<List<T, U>>, typename ZipHelper<List<Ts...>, List<Us...>>::Type>> {};
214template<concepts::TypeList T, concepts::TypeList U>
219 template<
typename T, usize N>
228 template<
typename T, usize N>
230 struct RepeatHelper<T, N>
231 :
TypeConstant<Concat<Type<RepeatHelper<T, N / 2>>, Type<RepeatHelper<T, (N + 1) / 2>>>> {};
234template<
typename T, usize N>
238 template<
typename... Types>
239 struct CartesianProductHelper {};
242 struct CartesianProductHelper<> :
TypeConstant<List<List<>>> {};
244 template<
typename... Types>
245 struct CartesianProductHelper<
List<Types...>> :
TypeConstant<List<List<Types>...>> {};
247 template<
typename... Ts,
typename... Rest>
248 struct CartesianProductHelper<
List<Ts...>, Rest...>
249 :
TypeConstant<Concat<Transform<Type<CartesianProductHelper<Rest...>>, BindBack<Quote<PushFront>, Ts>>...>> {};
256 template<
typename...>
257 struct ConcatVHelper {};
259 template<
auto... ts,
auto... us,
typename... Rest>
260 struct ConcatVHelper<
ListV<ts...>,
ListV<us...>, Rest...> : ConcatVHelper<ListV<ts..., us...>, Rest...> {};
269template<concepts::InstanceOfV<ListV>... Lists>
274 struct ReverseVHelper {};
282 template<
auto v,
auto... vs>
283 struct ReverseVHelper<
ListV<v, vs...>> :
TypeConstant<ConcatV<Type<ReverseVHelper<ListV<vs...>>>, ListV<v>>> {};
286template<concepts::InstanceOfV<ListV> List>
293#if __has_builtin(__make_integer_seq)
294 template<
typename T, T... ns>
295 using ConvertToListV =
ListV<ns...>;
296#elif __has_builtin(__integer_pack)
297 template<
typename T,
auto... ns>
298 using ConvertToListV =
ListV<T(ns)...>;
300 template<
typename T,
typename X,
typename Y>
301 struct MakeIntegerSequenceConcatHelper;
303 template<
typename T, T... s1, T... s2>
304 struct MakeIntegerSequenceConcatHelper<T,
ListV<s1...>,
ListV<s2...>> {
305 using Type =
ListV<s1..., (T(
sizeof...(s1) + s2))...>;
308 template<
typename T, usize count>
309 struct MakeIntegerSequenceHelper {
316 struct MakeIntegerSequenceHelper<T, 1> :
TypeConstant<ListV<T(0)>> {};
319 struct MakeIntegerSequenceHelper<T, 0> :
TypeConstant<ListV<>> {};
323template<
typename T, usize count>
324#if __has_builtin(__make_integer_seq)
326#elif __has_builtin(__integer_pack)
338template<
typename... Types>
constexpr auto count
Definition count.h:37