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
 Base struct containing traits of specified template (which only accepts type parameters) More...
 
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...
 

Concepts

concept  CIsTypeList
 Concept constraining a given type to TTypes
 
concept  CIsTemplate
 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, 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, 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<CIsTypeList T, size_t I>
using TTypes_Get = T::template Get<I>
 
template<CIsTypeList T, size_t I>
using TTypes_GetDecay = T::template GetDecay<I>
 
template<template< typename... > typename Template, typename Instance >
using TTemplate_Params = typename TTemplate<Template>::template Parameters<Instance>::Type
 Get template type parameters as a tuple.
 
template<template< typename... > typename Template, typename Instance >
using TTemplate_ParamsDecay = typename TTemplate<Template>::template ParametersDecay<Instance>::Type
 Get decayed template type parameters as a tuple.
 
template<template< typename... > typename Template, typename Instance , int I>
using TTemplate_Param = typename TTemplate<Template>::template Param<Instance, I>
 Get a type parameter at a specified position of a templated instance.
 
template<template< typename... > typename Template, typename Instance , int I>
using TTemplate_ParamDecay = typename TTemplate<Template>::template ParamDecay<Instance, I>
 Get a decayed type parameter at a specified position of a templated instance.
 

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<template< typename... > typename Template, typename Instance >
constexpr size_t TTemplate_ParamCount = TTemplate<Template>::template ParameterCount<Instance>
 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

◆ TLastTypeAtPack

template<size_t I, typename... Rest>
using Mcro::Templates::TLastTypeAtPack = typename TTypeAtPack_Struct<sizeof...(Rest) - I, 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 66 of file Templates.h.

◆ TLastTypeAtPackDecay

template<size_t I, typename... Rest>
using Mcro::Templates::TLastTypeAtPackDecay = std::decay_t<typename TTypeAtPack_Struct<sizeof...(Rest) - I, 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 82 of file Templates.h.

◆ TTemplate_Param

template<template< typename... > typename Template, typename Instance , int I>
using Mcro::Templates::TTemplate_Param = typename TTemplate<Template>::template Param<Instance, 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 217 of file Templates.h.

◆ TTemplate_ParamDecay

template<template< typename... > typename Template, typename Instance , int I>
using Mcro::Templates::TTemplate_ParamDecay = typename TTemplate<Template>::template ParamDecay<Instance, 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 228 of file Templates.h.

◆ TTemplate_Params

template<template< typename... > typename Template, typename Instance >
using Mcro::Templates::TTemplate_Params = typename TTemplate<Template>::template Parameters<Instance>::Type

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 195 of file Templates.h.

◆ TTemplate_ParamsDecay

template<template< typename... > typename Template, typename Instance >
using Mcro::Templates::TTemplate_ParamsDecay = typename TTemplate<Template>::template ParametersDecay<Instance>::Type

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 206 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 58 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 74 of file Templates.h.

◆ TTypes_Get

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

Definition at line 127 of file Templates.h.

◆ TTypes_GetDecay

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

Definition at line 130 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 255 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 271 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 275 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 263 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 283 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 279 of file Templates.h.

Variable Documentation

◆ TTemplate_ParamCount

template<template< typename... > typename Template, typename Instance >
size_t Mcro::Templates::TTemplate_ParamCount = TTemplate<Template>::template ParameterCount<Instance>
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 251 of file Templates.h.