Navigation
API > API/Runtime > API/Runtime/Core > API/Runtime/Core/Misc
Inheritance Hierarchy
- TVariantStorage
- TVariant
References
| Module | Core |
| Header | /Engine/Source/Runtime/Core/Public/Misc/TVariant.h |
| Include | #include "Misc/TVariant.h" |
Syntax
template<typename T, typename... Ts>
class TVariant : private UE::Core::Private::TVariantStorage< T, Ts... >
Remarks
A type-safe union based loosely on std::variant. This flavor of variant requires that all the types in the declaring template parameter pack be unique. Attempting to use the value of a Get() when the underlying type is different leads to undefined behavior.
Constructors
| Type | Name | Description | |
|---|---|---|---|
TVariant () |
Test for 255 here, because the parameter pack doesn't include the initial T. | ||
| Copy construct the variant from another variant of the same type | |||
| Move construct the variant from another variant of the same type | |||
TVariant
(
TInPlaceType< U >&&, |
Perform in-place construction of a type into the variant |
Destructors
| Type | Name | Description | |
|---|---|---|---|
~TVariant () |
Destruct the underlying type (if appropriate) |
Functions
| Type | Name | Description | |
|---|---|---|---|
| void | Emplace
(
TArgs&&... Args |
Set a specifically-typed value into the variant using in-place construction | |
| U & | Get () |
Get a reference to the held value. | |
| const U & | Get () |
Get a reference to the held value. | |
| SIZE_T | GetIndex () |
Returns the currently held type's index into the template parameter pack | |
| constexpr SIZE_T | IndexOfType () |
Lookup the index of a type in the template parameter pack at compile time. | |
| bool | IsType () |
Determine if the variant holds the specific type | |
| void | Set a specifically-typed value into the variant | ||
| void | Set a specifically-typed value into the variant | ||
| U * | TryGet () |
Get a pointer to the held value if the held type is the same as the one specified | |
| const U * | TryGet () |
Get a pointer to the held value if the held type is the same as the one specified |