Navigation
API > API/Runtime > API/Runtime/Core
Represents a type which is the union of several other types; i.e. it can have a value whose type is of any the union's subtypes. This differs from C union types by being type-safe, and supporting non-trivial data types as subtypes. Since a value for the union must be of a single subtype, the union stores potential values of different subtypes in overlapped memory, and keeps track of which one is currently valid.
TUnion should be considered deprecated and TVariant should be used instead for new code.
| Name | TUnion |
| Type | class |
| Header File | /Engine/Source/Runtime/Core/Public/Containers/Union.h |
| Include Path | #include "Containers/Union.h" |
Syntax
template<typename TypeA, typename TypeB, typename TypeC, typename TypeD, typename TypeE, typename TypeF>
class TUnion
Derived Classes
Constructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
TUnion () |
Default constructor. | Containers/Union.h | |
| Copy constructor. | Containers/Union.h | ||
TUnion
(
typename TCallTraits< TypeA >::ParamType InValue, |
Initialization constructor. | Containers/Union.h | |
TUnion
(
typename TCallTraits< TypeB >::ParamType InValue, |
Initialization constructor. | Containers/Union.h | |
TUnion
(
typename TCallTraits< TypeC >::ParamType InValue, |
Initialization constructor. | Containers/Union.h | |
TUnion
(
typename TCallTraits< TypeD >::ParamType InValue, |
Initialization constructor. | Containers/Union.h | |
TUnion
(
typename TCallTraits< TypeE >::ParamType InValue, |
Initialization constructor. | Containers/Union.h | |
TUnion
(
typename TCallTraits< TypeF >::ParamType InValue, |
Initialization constructor. | Containers/Union.h |
Destructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
~TUnion() |
Destructor. | Containers/Union.h |
Variables
Public
| Name | Type | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|---|
| A | TTypeCompatibleBytes< TypeA > | Containers/Union.h | ||
| B | TTypeCompatibleBytes< TypeB > | Containers/Union.h | ||
| C | TTypeCompatibleBytes< TypeC > | Containers/Union.h | ||
| D | TTypeCompatibleBytes< TypeD > | Containers/Union.h | ||
| E | TTypeCompatibleBytes< TypeE > | Containers/Union.h | ||
| F | TTypeCompatibleBytes< TypeF > | Containers/Union.h |
Protected
| Name | Type | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|---|
| CurrentSubtypeIndex | uint8 | The index of the subtype that the union's current value is of. | Containers/Union.h | |
| Values | union TUnion | The potential values for each subtype of the union. | Containers/Union.h |
Functions
Public
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
uint8 GetCurrentSubtypeIndex() |
Containers/Union.h | ||
Subtype & GetSubtype () |
Containers/Union.h | ||
const Subtype & GetSubtype () |
Containers/Union.h | ||
bool HasSubtype() |
Containers/Union.h | ||
void Reset() |
Sets the union's value to NULL. | Containers/Union.h | |
void ResetSubtype() |
If the union's current value is of the given subtype, sets the union's value to a NULL value. | Containers/Union.h | |
void Serialize
(
FArchive& Ar |
Containers/Union.h | ||
Subtype * SetSubtype
(
typename TCallTraits< Subtype >::ParamType NewValue |
Replaces the value of the union with a value of the given subtype. | Containers/Union.h | |
Subtype * SetSubtype () |
Replaces the value of the union with a value of the given subtype. | Containers/Union.h |
Static
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
static void FatalErrorUndefinedSubtype() |
Containers/Union.h | ||
static void GetSubtypeIndexAndReference
(
const TUnion& Union, |
Determines the index and reference to the potential value for the given union subtype. | Containers/Union.h |
Operators
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
| Containers/Union.h | |||
bool operator==
(
const TUnion& Other |
Equality comparison. | Containers/Union.h |