14#include "CoreMinimal.h"
27 template <
size_t I,
typename First = void,
typename... Rest>
33 template <
typename First,
typename... Rest>
40 template <
size_t I,
typename... T>
43 static_assert(I <=
sizeof...(T),
"Indexing parameter pack out of its bounds.");
58 template<
size_t I,
typename... Rest>
66 template<
size_t I,
typename... Rest>
74 template<
size_t I,
typename... Rest>
82 template<
size_t I,
typename... Rest>
85 template <
size_t I,
typename T>
88 static_assert(
sizeof(T) == 0,
"TTupleSafeElement_Struct is instantiated with non TTuple.");
91 template <
size_t I,
typename... T>
105 template <
typename... T>
108 static constexpr size_t Count =
sizeof...(T);
117 template <
typename T>
120 template <
typename... T>
124 template <
typename T>
127 template <CTypeList T,
size_t I>
130 template <CTypeList T,
size_t I>
136 template <
CTypeList T,
size_t... Indices>
139 template <
size_t Count, CTypeList T>
140 requires (T::Count >= Count)
146 template <
size_t... Indices>
150 Compose(std::make_index_sequence<T::Count - Count>{})
157 template <
size_t Count, CTypeList T>
160 template <
size_t Count, CTypeList T>
161 requires (T::Count >= Count)
167 template <
size_t... Indices>
171 Compose(std::make_index_sequence<T::Count - Count>{})
178 template <
size_t Count,
typename T>
181 template <
size_t Count,
typename T>
182 requires (T::Count >= Count)
188 template <
size_t... Indices>
192 Compose(std::make_index_sequence<Count>{})
199 template <
size_t Count,
typename T>
204 template <
CTypeList TypeList,
auto Test,
size_t... Indices>
205 consteval bool AllOfTypeList(
bool onEmpty, std::index_sequence<Indices...>&&)
207 if constexpr (
sizeof...(Indices) == 0)
213 template <
CTypeList TypeList,
auto Test,
size_t... Indices>
216 if constexpr (
sizeof...(Indices) == 0)
222 template <
CTypeList TypeList,
auto Test,
size_t... Indices>
223 consteval bool AnyOfTypeList(
bool onEmpty, std::index_sequence<Indices...>&&)
225 if constexpr (
sizeof...(Indices) == 0)
231 template <
CTypeList TypeList,
auto Test,
size_t... Indices>
234 if constexpr (
sizeof...(Indices) == 0)
243 if constexpr (
sizeof...(Indices) == 0)
252 if constexpr (
sizeof...(Indices) == 0)
259#define MCRO_TYPE_LIST_PREDICATE(Function, TypeList, OnEmpty, ...) \
261 BOOST_PP_REMOVE_PARENS(TypeList), \
262 [] <typename T> (TTypes<T>&&) { return __VA_ARGS__; } \
263 >(OnEmpty, std::make_index_sequence<BOOST_PP_REMOVE_PARENS(TypeList)::Count>())
272#define ALL_OF_TYPE_LIST(typeList, onEmpty, ...) MCRO_TYPE_LIST_PREDICATE(Detail::AllOfTypeList, typeList, onEmpty, __VA_ARGS__)
283#define C_ALL_OF_TYPE_LIST(typeList, onEmpty, conceptIn, ...) ALL_OF_TYPE_LIST(typeList, onEmpty, conceptIn<T __VA_OPT__(,) __VA_ARGS__>)
292#define ANY_OF_TYPE_LIST(typeList, onEmpty, ...) MCRO_TYPE_LIST_PREDICATE(Detail::AnyOfTypeList, typeList, onEmpty, __VA_ARGS__)
303#define C_ANY_OF_TYPE_LIST(typeList, onEmpty, conceptIn, ...) ANY_OF_TYPE_LIST(typeList, onEmpty, conceptIn<T __VA_OPT__(,) __VA_ARGS__>)
312#define ALL_OF_TYPE_PACK(TypePack, onEmpty, ...) ALL_OF_TYPE_LIST(TTypes<TypePack...>, onEmpty, __VA_ARGS__)
323#define C_ALL_OF_TYPE_PACK(TypePack, onEmpty, conceptIn, ...) C_ALL_OF_TYPE_LIST(TTypes<TypePack...>, onEmpty, conceptIn, __VA_ARGS__)
332#define ANY_OF_TYPE_PACK(TypePack, onEmpty, ...) ANY_OF_TYPE_LIST(TTypes<TypePack...>, onEmpty, __VA_ARGS__)
343#define C_ANY_OF_TYPE_PACK(TypePack, onEmpty, conceptIn, ...) C_ANY_OF_TYPE_LIST(TTypes<TypePack...>, onEmpty, conceptIn, __VA_ARGS__)
350 template <
typename From,
typename To,
bool OnEmpty = true>
354 && From::Count == To::Count
357 std::make_index_sequence<From::Count>()
366 template <
typename From,
typename To,
bool OnEmpty = true>
370 && From::Count == To::Count
373 std::make_index_sequence<From::Count>()
385 template <
template <
typename...>
typename Template>
388 template <
typename T>
389 static constexpr bool Match =
false;
391 template <
typename... Params>
392 static constexpr bool Match<Template<Params...>> =
true;
409 template <
template <
typename...>
typename Template,
typename... Params>
414 static constexpr size_t ParameterCount =
sizeof...(Params);
433 template <
typename T>
444 template <CTypeOnlyTemplate Instance>
455 template <CTypeOnlyTemplate Instance>
466 template <CTypeOnlyTemplate Instance,
int I>
477 template <CTypeOnlyTemplate Instance,
int I>
488 template <
typename Instance,
template <
typename...>
typename Template>
491 && TTemplate_Match<Template>::template Match<std::decay_t<Instance>>
503 template <CTypeOnlyTemplate Instance>
506 template <
template <
typename...>
typename,
typename>
513 template <
typename...>
typename TemplateOut,
514 template <
typename...>
typename TemplateIn,
519 using Type = TemplateOut<Params...>;
532 template <
template <
typename...>
typename TemplateOut,
CTypeOnlyTemplate FromInstance>
536 template <CConstType T>
540 template <CMutableType T>
541 constexpr auto&&
AsConst(T&& input) {
return FWD(
const_cast<const T
>(input)); }
544 template <CMutableType T>
548 template <CConstType T>
549 constexpr auto&&
AsMutable(T&& input) {
return FWD(
const_cast<T
>(input)); }
552 template <
typename T>
556 template <
typename T>
557 constexpr auto AsConstPtr(T* input) {
return const_cast<const T*
>(input); }
560 template <
typename T>
564 template <
typename T>
565 constexpr auto AsMutablePtr(
const T* input) {
return const_cast<T*
>(input); }
This header exists because STL headers in Android doesn't define STL concepts (other than same_as whi...
#define FWD(...)
Shorten forwarding expression with this macro so one may not need to specify explicit type.
Check if given type is an instantiation of a given template (which only accepts type parameters)
Concept constraining a given type to TTypes
Checks if input is a template which only has type parameters.
Is given type-list contains all types convertible to the types of another type-list....
Is given type-list contains all types convertible to the types of another type-list....
consteval bool AnyOfTypeList(bool onEmpty, std::index_sequence< Indices... > &&)
consteval bool AnyOfTypeListDecay(bool onEmpty, std::index_sequence< Indices... > &&)
consteval bool AllOfTypeList(bool onEmpty, std::index_sequence< Indices... > &&)
consteval bool AllOfTypeListDecay(bool onEmpty, std::index_sequence< Indices... > &&)
consteval bool IsTypeListConvertibleToDecay(bool onEmpty, std::index_sequence< Indices... > &&)
consteval bool IsTypeListConvertibleTo(bool onEmpty, std::index_sequence< Indices... > &&)
This namespace provides templating utilities and introspection into template instantiations.
typename TTypeAtPack_Struct< I, Rest... >::Type TTypeAtPack
Get a specific item from a parameter pack at given index. It is an unspecified compile error to index...
std::decay_t< typename TTypeAtPack_Struct< sizeof...(Rest) - I - 1, Rest... >::Type > TLastTypeAtPackDecay
Get a specific item from the end of a parameter pack at given index (0 == last) disregarding CV-ref q...
std::decay_t< typename TTypeAtPack_Struct< I, Rest... >::Type > TTypeAtPackDecay
Get a specific item from a parameter pack at given index disregarding CV-ref qualifiers....
constexpr size_t TTemplate_ParamCount
Get the number of template type parameters from a specified templated instance (which only has type p...
T::template Get< I > TTypes_Get
typename TTemplateMap_Struct< TemplateOut, FromInstance >::Type TTemplateMap
Transfer parameters from one template to another. Or in other words replace the template part of the ...
constexpr auto AsMutablePtr(T *input)
Tired of typing const_cast<FMyLongUnwieldyTypeName*>(...)? use this instead.
typename TTemplate_Struct< Instance >::template ParamDecay< I > TTemplate_ParamDecay
Get a decayed type parameter at a specified position of a templated instance.
typename TTemplate_Struct< Instance >::Parameters TTemplate_Params
Get template type parameters as a tuple.
constexpr auto && AsMutable(T &&input)
Tired of typing const_cast<FMyLongUnwieldyTypeName>(...)? use this instead.
typename TTypesSkip_Struct< Count, T >::Type TTypesSkip
typename TTypeAtPack_Struct< sizeof...(Rest) - I - 1, Rest... >::Type TLastTypeAtPack
Get a specific item from the end of a parameter pack at given index (0 == last). It is an unspecified...
T::template GetDecay< I > TTypes_GetDecay
typename TTemplate_Struct< Instance >::template Param< I > TTemplate_Param
Get a type parameter at a specified position of a templated instance.
typename TTypesTrimEnd_Struct< Count, T >::Type TTypesTrimEnd
constexpr auto AsConstPtr(const T *input)
Tired of typing const_cast<FMyLongUnwieldyTypeName*>(...)? use this instead.
typename TTemplate_Struct< Instance >::ParametersDecay TTemplate_ParamsDecay
Get decayed template type parameters as a tuple.
constexpr auto && AsConst(T &&input)
Tired of typing const_cast<FMyLongUnwieldyTypeName>(...)? use this instead.
typename TTypesTake_Struct< Count, T >::Type TTypesTake
typename TTypeAtPack_Impl< I - 1, Rest... >::Type Type
static constexpr bool Value
TemplateOut< Params... > Type
Base struct for matching templates disregarding their arguments.
static constexpr bool Match
TTypeAtPack< I, Params... > Param
TTypes_Get< ParametersDecay, I > ParamDecay
static constexpr bool IsTemplate
TTypeAtPack< I, T... > Type
typename Detail::TTypeAtPack_Impl< I, T... >::Type Type
decltype( Compose(std::make_index_sequence< T::Count - Count >{})) Type
static consteval TComposeTypeListFrom< T,(Indices+Count)... > Compose(std::index_sequence< Indices... > &&)
decltype( Compose(std::make_index_sequence< Count >{})) Type
static consteval TComposeTypeListFrom< T, Indices... > Compose(std::index_sequence< Indices... > &&)
static consteval TComposeTypeListFrom< T, Indices... > Compose(std::index_sequence< Indices... > &&)
decltype( Compose(std::make_index_sequence< T::Count - Count >{})) Type
This template is used to store pack of types in other templates, or to allow parameter pack inference...
TTypeAtPack< I, T... > Get
TTypeAtPackDecay< I, T... > GetDecay
static constexpr size_t Count