MCRO
C++23 utilities for Unreal Engine.
Loading...
Searching...
No Matches
Mcro::Templates Namespace Reference

This namespace provides templating utilities and introspection into template instantiations. More...

Namespaces

namespace  Detail
 

Data Structures

struct  TIsTypeList_Struct
 
struct  TIsTypeList_Struct< TTypes< T... > >
 
struct  TTemplate_Match
 Base struct for matching templates disregarding their arguments. More...
 
struct  TTemplate_Struct
 
struct  TTemplate_Struct< Template< Params... > >
 Base struct containing traits of specified template instance (which only accepts type parameters) More...
 
struct  TTemplateMap_Struct
 
struct  TTemplateMap_Struct< TemplateOut, TemplateIn< Params... > >
 
struct  TTupleSafeElement_Struct
 
struct  TTupleSafeElement_Struct< I, TTuple< T... > >
 
struct  TTypeAtPack_Struct
 
struct  TTypeAtPack_Struct< I >
 
struct  TTypes
 This template is used to store pack of types in other templates, or to allow parameter pack inference for functions. This template may be referred to as 'type-list' in other parts of the documentation. More...
 
struct  TTypesSkip_Struct
 
struct  TTypesTake_Struct
 
struct  TTypesTrimEnd_Struct
 

Concepts

concept  CTypeList
 Concept constraining a given type to TTypes
 
concept  CTypesConvertibleTo
 Is given type-list contains all types convertible to the types of another type-list. The number and order of types are significant.
 
concept  CTypesConvertibleToDecayed
 Is given type-list contains all types convertible to the types of another type-list. The number and order of types are significant. Qualifiers are not taken into account.
 
concept  CTypeOnlyTemplate
 Checks if input is a template which only has type parameters.
 
concept  CMatchTemplate
 Check if given type is an instantiation of a given template (which only accepts type parameters)
 

Typedefs

template<size_t I, typename... Rest>
using TTypeAtPack = typename TTypeAtPack_Struct<I, Rest...>::Type
 Get a specific item from a parameter pack at given index. It is an unspecified compile error to index an empty parameter pack.
 
template<size_t I, typename... Rest>
using TLastTypeAtPack = typename TTypeAtPack_Struct<sizeof...(Rest) - I - 1, Rest...>::Type
 Get a specific item from the end of a parameter pack at given index (0 == last). It is an unspecified compile error to index an empty parameter pack.
 
template<size_t I, typename... Rest>
using TTypeAtPackDecay = std::decay_t<typename TTypeAtPack_Struct<I, Rest...>::Type>
 Get a specific item from a parameter pack at given index disregarding CV-ref qualifiers. It is an unspecified compile error to index an empty parameter pack.
 
template<size_t I, typename... Rest>
using TLastTypeAtPackDecay = std::decay_t<typename TTypeAtPack_Struct<sizeof...(Rest) - I - 1, Rest...>::Type>
 Get a specific item from the end of a parameter pack at given index (0 == last) disregarding CV-ref qualifiers. It is an unspecified compile error to index an empty parameter pack.
 
template<CTypeList T, size_t I>
using TTypes_Get = T::template Get<I>
 
template<CTypeList T, size_t I>
using TTypes_GetDecay = T::template GetDecay<I>
 
template<CTypeList T, size_t... Indices>
using TComposeTypeListFrom = TTypes<TTypes_Get<T, Indices>...>
 
template<size_t Count, CTypeList T>
using TTypesSkip = typename TTypesSkip_Struct<Count, T>::Type
 
template<size_t Count, typename T >
using TTypesTrimEnd = typename TTypesTrimEnd_Struct<Count, T>::Type
 
template<size_t Count, typename T >
using TTypesTake = typename TTypesTake_Struct<Count, T>::Type
 
template<CTypeOnlyTemplate Instance>
using TTemplate_Params = typename TTemplate_Struct<Instance>::Parameters
 Get template type parameters as a tuple.
 
template<CTypeOnlyTemplate Instance>
using TTemplate_ParamsDecay = typename TTemplate_Struct<Instance>::ParametersDecay
 Get decayed template type parameters as a tuple.
 
template<CTypeOnlyTemplate Instance, int I>
using TTemplate_Param = typename TTemplate_Struct<Instance>::template Param<I>
 Get a type parameter at a specified position of a templated instance.
 
template<CTypeOnlyTemplate Instance, int I>
using TTemplate_ParamDecay = typename TTemplate_Struct<Instance>::template ParamDecay<I>
 Get a decayed type parameter at a specified position of a templated instance.
 
template<template< typename... > typename TemplateOut, CTypeOnlyTemplate FromInstance>
using TTemplateMap = typename TTemplateMap_Struct<TemplateOut, FromInstance>::Type
 Transfer parameters from one template to another. Or in other words replace the template part of the input template instance with TemplateOut.
 

Functions

template<CConstType T>
constexpr auto && AsConst (T &&input)
 Tired of typing const_cast<FMyLongUnwieldyTypeName>(...)? use this instead.
 
template<CMutableType T>
constexpr auto && AsMutable (T &&input)
 Tired of typing const_cast<FMyLongUnwieldyTypeName>(...)? use this instead.
 
template<typename T >
constexpr auto AsConstPtr (const T *input)
 Tired of typing const_cast<FMyLongUnwieldyTypeName*>(...)? use this instead.
 
template<typename T >
constexpr auto AsConstPtr (T *input)
 Tired of typing const_cast<FMyLongUnwieldyTypeName*>(...)? use this instead.
 
template<typename T >
constexpr auto AsMutablePtr (T *input)
 Tired of typing const_cast<FMyLongUnwieldyTypeName*>(...)? use this instead.
 
template<typename T >
constexpr auto AsMutablePtr (const T *input)
 Tired of typing const_cast<FMyLongUnwieldyTypeName*>(...)? use this instead.
 

Variables

template<CTypeOnlyTemplate Instance>
constexpr size_t TTemplate_ParamCount = TTemplate_Struct<Instance>::ParameterCount
 Get the number of template type parameters from a specified templated instance (which only has type parameters)
 

Detailed Description

This namespace provides templating utilities and introspection into template instantiations.

Typedef Documentation

◆ TComposeTypeListFrom

template<CTypeList T, size_t... Indices>
using Mcro::Templates::TComposeTypeListFrom = TTypes<TTypes_Get<T, Indices>...>

Compose a type-list out of the elements of the input type-list based on the input index parameter pack

Definition at line 137 of file Templates.h.

◆ TLastTypeAtPack

template<size_t I, typename... Rest>
using Mcro::Templates::TLastTypeAtPack = typename TTypeAtPack_Struct<sizeof...(Rest) - I - 1, Rest...>::Type

Get a specific item from the end of a parameter pack at given index (0 == last). It is an unspecified compile error to index an empty parameter pack.

Definition at line 67 of file Templates.h.

◆ TLastTypeAtPackDecay

template<size_t I, typename... Rest>
using Mcro::Templates::TLastTypeAtPackDecay = std::decay_t<typename TTypeAtPack_Struct<sizeof...(Rest) - I - 1, Rest...>::Type>

Get a specific item from the end of a parameter pack at given index (0 == last) disregarding CV-ref qualifiers. It is an unspecified compile error to index an empty parameter pack.

Definition at line 83 of file Templates.h.

◆ TTemplate_Param

template<CTypeOnlyTemplate Instance, int I>
using Mcro::Templates::TTemplate_Param = typename TTemplate_Struct<Instance>::template Param<I>

Get a type parameter at a specified position of a templated instance.

Warning
Until this proposal https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p1985r0.pdf or equivalent is considered seriously, template traits only work with templates which only have type-parameters. Non-type parameters even when a default is specified for them will result in compile error.

Definition at line 467 of file Templates.h.

◆ TTemplate_ParamDecay

template<CTypeOnlyTemplate Instance, int I>
using Mcro::Templates::TTemplate_ParamDecay = typename TTemplate_Struct<Instance>::template ParamDecay<I>

Get a decayed type parameter at a specified position of a templated instance.

Warning
Until this proposal https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p1985r0.pdf or equivalent is considered seriously, template traits only work with templates which only have type-parameters. Non-type parameters even when a default is specified for them will result in compile error.

Definition at line 478 of file Templates.h.

◆ TTemplate_Params

template<CTypeOnlyTemplate Instance>
using Mcro::Templates::TTemplate_Params = typename TTemplate_Struct<Instance>::Parameters

Get template type parameters as a tuple.

Warning
Until this proposal https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p1985r0.pdf or equivalent is considered seriously, template traits only work with templates which only have type-parameters. Non-type parameters even when a default is specified for them will result in compile error.

Definition at line 445 of file Templates.h.

◆ TTemplate_ParamsDecay

template<CTypeOnlyTemplate Instance>
using Mcro::Templates::TTemplate_ParamsDecay = typename TTemplate_Struct<Instance>::ParametersDecay

Get decayed template type parameters as a tuple.

Warning
Until this proposal https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p1985r0.pdf or equivalent is considered seriously, template traits only work with templates which only have type-parameters. Non-type parameters even when a default is specified for them will result in compile error.

Definition at line 456 of file Templates.h.

◆ TTemplateMap

template<template< typename... > typename TemplateOut, CTypeOnlyTemplate FromInstance>
using Mcro::Templates::TTemplateMap = typename TTemplateMap_Struct<TemplateOut, FromInstance>::Type

Transfer parameters from one template to another. Or in other words replace the template part of the input template instance with TemplateOut.

Warning
Until this proposal https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p1985r0.pdf or equivalent is considered seriously, template traits only work with templates which only have type-parameters. Non-type parameters even when a default is specified for them will result in compile error.

Definition at line 533 of file Templates.h.

◆ TTypeAtPack

template<size_t I, typename... Rest>
using Mcro::Templates::TTypeAtPack = typename TTypeAtPack_Struct<I, Rest...>::Type

Get a specific item from a parameter pack at given index. It is an unspecified compile error to index an empty parameter pack.

Definition at line 59 of file Templates.h.

◆ TTypeAtPackDecay

template<size_t I, typename... Rest>
using Mcro::Templates::TTypeAtPackDecay = std::decay_t<typename TTypeAtPack_Struct<I, Rest...>::Type>

Get a specific item from a parameter pack at given index disregarding CV-ref qualifiers. It is an unspecified compile error to index an empty parameter pack.

Definition at line 75 of file Templates.h.

◆ TTypes_Get

template<CTypeList T, size_t I>
using Mcro::Templates::TTypes_Get = T::template Get<I>

Definition at line 128 of file Templates.h.

◆ TTypes_GetDecay

template<CTypeList T, size_t I>
using Mcro::Templates::TTypes_GetDecay = T::template GetDecay<I>

Definition at line 131 of file Templates.h.

◆ TTypesSkip

template<size_t Count, CTypeList T>
using Mcro::Templates::TTypesSkip = typename TTypesSkip_Struct<Count, T>::Type

Skip the first Count elements of the input type-list

Definition at line 158 of file Templates.h.

◆ TTypesTake

template<size_t Count, typename T >
using Mcro::Templates::TTypesTake = typename TTypesTake_Struct<Count, T>::Type

Take only the first Count elements of the input type-list

Definition at line 200 of file Templates.h.

◆ TTypesTrimEnd

template<size_t Count, typename T >
using Mcro::Templates::TTypesTrimEnd = typename TTypesTrimEnd_Struct<Count, T>::Type

Disregard the last Count elements of the input type-list

Definition at line 179 of file Templates.h.

Function Documentation

◆ AsConst()

template<CConstType T>
auto && Mcro::Templates::AsConst ( T && input)
constexpr

Tired of typing const_cast<FMyLongUnwieldyTypeName>(...)? use this instead.

Definition at line 537 of file Templates.h.

◆ AsConstPtr() [1/2]

template<typename T >
auto Mcro::Templates::AsConstPtr ( const T * input)
constexpr

Tired of typing const_cast<FMyLongUnwieldyTypeName*>(...)? use this instead.

Definition at line 553 of file Templates.h.

◆ AsConstPtr() [2/2]

template<typename T >
auto Mcro::Templates::AsConstPtr ( T * input)
constexpr

Tired of typing const_cast<FMyLongUnwieldyTypeName*>(...)? use this instead.

Definition at line 557 of file Templates.h.

◆ AsMutable()

template<CMutableType T>
auto && Mcro::Templates::AsMutable ( T && input)
constexpr

Tired of typing const_cast<FMyLongUnwieldyTypeName>(...)? use this instead.

Definition at line 545 of file Templates.h.

◆ AsMutablePtr() [1/2]

template<typename T >
auto Mcro::Templates::AsMutablePtr ( const T * input)
constexpr

Tired of typing const_cast<FMyLongUnwieldyTypeName*>(...)? use this instead.

Definition at line 565 of file Templates.h.

◆ AsMutablePtr() [2/2]

template<typename T >
auto Mcro::Templates::AsMutablePtr ( T * input)
constexpr

Tired of typing const_cast<FMyLongUnwieldyTypeName*>(...)? use this instead.

Definition at line 561 of file Templates.h.

Variable Documentation

◆ TTemplate_ParamCount

template<CTypeOnlyTemplate Instance>
size_t Mcro::Templates::TTemplate_ParamCount = TTemplate_Struct<Instance>::ParameterCount
inlineconstexpr

Get the number of template type parameters from a specified templated instance (which only has type parameters)

Warning
Until this proposal https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p1985r0.pdf or equivalent is considered seriously, template traits only work with templates which only have type-parameters. Non-type parameters even when a default is specified for them will result in compile error.

Definition at line 504 of file Templates.h.