Type‐safe discriminated union of alternative types.

Synopsis

Declared in <bslstl_variant.h>

template<
    class t_HEAD,
    class... t_TAIL>
class variant;

Type Aliases

Name

Description

allocator_type

Type alias to the allocator type used by variant.

Member Functions

Name

Description

variant [constructor]

Constructors

operator=

Assignment operators

emplace

emplace overloads

get_allocator

Return a copy of this object's allocator.

index

Return the index of the currently managed alternative.

swap

Efficiently exchange the value of this object with other's value.

valueless_by_exception

Return true if this object is valueless by exception.

operator BloombergLP::bslmf::NestedTraitDeclaration<variant, IsBitwiseMoveable, (BloombergLP::bslstl::Variant_IsBitwiseMoveableAll<t_HEAD, t_TAIL...>::value)>

Nested trait declaration for IsBitwiseMoveable.

operator BloombergLP::bslmf::NestedTraitDeclaration<variant, UsesAllocatorArgT, (BloombergLP::bslstl::Variant_UsesBslmaAllocatorAny<t_HEAD, t_TAIL...>::value)>

Nested trait declaration for UsesAllocatorArgT.

operator BloombergLP::bslmf::NestedTraitDeclaration<variant, UsesBslmaAllocator, (BloombergLP::bslstl::Variant_UsesBslmaAllocatorAny<t_HEAD, t_TAIL...>::value)>

Nested trait declaration for UsesBslmaAllocator.

Friends

Name

Description

BloombergLP::bslstl::Variant_Base

Define the data representation and special member functions of bsl::variant.

Non-Member Functions

Name

Description

get

See the first get overload above.

get

See the first get overload above.

get

See the first get overload above.

get

Return a reference to the alternative at index t_INDEX in obj.

get

See the first get overload above.

get

See the first get overload above.

get

Return a reference to the alternative of type t_TYPE in obj.

get

See the first get overload above.

get_if

Return a pointer to the t_TYPE alternative in obj if active.

get_if

Return a pointer to the t_TYPE alternative in obj if active.

get_if

Return a pointer to the alternative at index t_INDEX, or null.

get_if

Return a pointer to the alternative at index t_INDEX in obj, or null.

holds_alternative

Return true if obj currently holds the t_TYPE alternative.

operator!=

Return true if lhs and rhs are not equal.

operator<

Return true if lhs is less than rhs.

operator<=

Return true if lhs is less than or equal to rhs.

operator<=>

Return the three‐way comparison result of lhs and rhs.

operator==

Return true if lhs and rhs are equal.

operator>

Return true if lhs is greater than rhs.

operator>=

Return true if lhs is greater than or equal to rhs.

swap

Efficiently exchange the values of the specified lhs and rhs objects.

Created with MrDocs