TUnion

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.

Choose your operating system:

Windows

macOS

Linux

References

Module

Core

Header

/Engine/Source/Runtime/Core/Public/Containers/Union.h

Include

#include "Containers/Union.h"

Syntax

template<typename TypeA, typename TypeB, typename TypeC, typename TypeD, typename TypeE, typename TypeF>
class TUnion

Remarks

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.

Variables

Constructors

Name Description

Public function

TUnion()

Default constructor.

Public function

TUnion

(
    const TUnion& Other
)

Copy constructor.

Public function

TUnion

(
    typename TCallTraits< TypeA >::Para...,
    TDisambiguater< 0 > Disambiguater
)

Initialization constructor.

Public function

TUnion

(
    typename TCallTraits< TypeB >::Para...,
    TDisambiguater< 1 > Disambiguater
)

Initialization constructor.

Public function

TUnion

(
    typename TCallTraits< TypeC >::Para...,
    TDisambiguater< 2 > Disambiguater
)

Initialization constructor.

Public function

TUnion

(
    typename TCallTraits< TypeD >::Para...,
    TDisambiguater< 3 > Disambiguater
)

Initialization constructor.

Public function

TUnion

(
    typename TCallTraits< TypeE >::Para...,
    TDisambiguater< 4 > Disambiguater
)

Initialization constructor.

Public function

TUnion

(
    typename TCallTraits< TypeF >::Para...,
    TDisambiguater< 5 > Disambiguater
)

Initialization constructor.

Destructors

Name Description

Public function

~TUnion()

Destructor.

Functions

Name Description

Public function Const

uint8

 

GetCurrentSubtypeIndex()

Public function Const

const Subtyp...

 

GetSubtype()

Public function

Subtype &

 

GetSubtype()

Public function Const

bool

 

HasSubtype()

Public function

void

 

Reset()

Sets the union's value to NULL.

Public function

void

 

ResetSubtype()

If the union's current value is of the given subtype, sets the union's value to a NULL value.

Public function

Subtype *...

 

SetSubtype

(
    typename TCallTraits< Subtype >::Pa...
)

Replaces the value of the union with a value of the given subtype.

Public function

Subtype *...

 

SetSubtype()

Replaces the value of the union with a value of the given subtype.

Operators

Name Description

Public function

TUnion &

 

operator=

(
    const TUnion& Other
)

Public function Const

bool

 

operator==

(
    const TUnion& Other
)

Equality comparison.