bsl::variant

Type-safe discriminated union of alternative types.

Synopsis

Declared in <bslstl_variant.h>

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

Type Aliases

NameDescription
allocator_type Type alias to the allocator type used by variant.

Member Functions

NameDescription
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

NameDescription
BloombergLP::bslstl::Variant_BaseDefine the data representation and special member functions of bsl::variant.

Non-Member Functions

NameDescription
getSee the first get overload above.
getSee the first get overload above.
getSee the first get overload above.
getReturn a reference to the alternative at index t_INDEX in obj.
getSee the first get overload above.
getSee the first get overload above.
getReturn a reference to the alternative of type t_TYPE in obj.
getSee the first get overload above.
get_ifReturn a pointer to the t_TYPE alternative in obj if active.
get_ifReturn a pointer to the t_TYPE alternative in obj if active.
get_ifReturn a pointer to the alternative at index t_INDEX, or null.
get_ifReturn a pointer to the alternative at index t_INDEX in obj, or null.
holds_alternativeReturn 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.
swapEfficiently exchange the values of the specified lhs and rhs objects.