MCRO
C++23 utilities for Unreal Engine.
|
Variables | |
template<typename T > | |
constexpr FStringView | TTypeName |
template<typename T > | |
constexpr FStdStringView | TTypeNameStd = GetCompileTimeTypeName<std::decay_t<T>>() |
template<typename T > | |
const FName | TTypeFName = FName(TTypeName<T>.Len(), TTypeName<T>.GetData()) |
template<typename T > | |
const FString | TTypeString = FString(TTypeName<T>.GetData(), TTypeName<T>.Len()) |
Convert types to string
const FName Mcro::TypeName::TTypeFName = FName(TTypeName<T>.Len(), TTypeName<T>.GetData()) |
Definition at line 142 of file TypeName.h.
|
constexpr |
Get a friendly string of an input type without using typeid(T).name()
Actually this method gives more predictable results across compilers than typeid(T).name()
but still not 100% the same. Besides TTypeName<T>
can deal with incomplete types as well, whereas typeid(T)
cannot (more on this in remarks). While it is more consistent across compilers, it is still not 100% consistent. Take templated types for instance where MSVC compiler will add "class" prefix in front of type arguments where GCC or CLang might not. Because of subtle differences like this, it is strongly discouraged to assume the exact format of the output of TTypeName<T>
Usage:
It is useful in templates where a type name should be known in runtime as well. (e.g.: Modular features)
I
might not be the same as TTypeName somewhere else with I
being fully defined)T | The type to be named |
Definition at line 131 of file TypeName.h.
|
constexpr |
Definition at line 138 of file TypeName.h.
const FString Mcro::TypeName::TTypeString = FString(TTypeName<T>.GetData(), TTypeName<T>.Len()) |
Definition at line 146 of file TypeName.h.