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.

Windows
MacOS
Linux

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

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.

Operators

Name Description

Public function Const

bool

 

operator==

(
    const TUnion& Other
)

Equality comparison.

References

Module

Core

Header

Runtime/Core/Public/Containers/Union.h

Welcome to the new Unreal Engine 4 Documentation site!

We're working on lots of new features including a feedback system so you can tell us how we are doing. It's not quite ready for use in the wild yet, so head over to the Documentation Feedback forum to tell us about this page or call out any issues you are encountering in the meantime.

We'll be sure to let you know when the new system is up and running.

Post Feedback