[#bsl-variant] = xref:bsl.adoc[bsl]::variant :relfileprefix: ../ :mrdocs: Type‐safe discriminated union of alternative types. == Synopsis Declared in `<bslstl_variant.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template< class t_HEAD, class... t_TAIL> class variant; ---- == Type Aliases [cols="1,4"] |=== | Name| Description | xref:bsl/variant/allocator_type.adoc[`allocator_type`] | Type alias to the allocator type used by `variant`. |=== == Member Functions [cols="1,4"] |=== | Name| Description | xref:bsl/variant/2constructor-0e.adoc[`variant`] [.small]#[constructor]# | Constructors | xref:bsl/variant/operator_assign-07.adoc[`operator=`] | Assignment operators | xref:bsl/variant/emplace-03.adoc[`emplace`] | `emplace` overloads | xref:bsl/variant/get_allocator.adoc[`get_allocator`] | Return a copy of this object's allocator. | xref:bsl/variant/index.adoc[`index`] | Return the index of the currently managed alternative. | xref:bsl/variant/swap.adoc[`swap`] | Efficiently exchange the value of this object with `other`'s value. | xref:bsl/variant/valueless_by_exception.adoc[`valueless_by_exception`] | Return `true` if this object is valueless by exception. | xref:bsl/variant/2conversion-0e.adoc[`operator BloombergLP::bslmf::NestedTraitDeclaration<variant, IsBitwiseMoveable, (BloombergLP::bslstl::Variant_IsBitwiseMoveableAll<t_HEAD, t_TAIL...>::value)>`] | Nested trait declaration for `IsBitwiseMoveable`. | xref:bsl/variant/2conversion-02.adoc[`operator BloombergLP::bslmf::NestedTraitDeclaration<variant, UsesAllocatorArgT, (BloombergLP::bslstl::Variant_UsesBslmaAllocatorAny<t_HEAD, t_TAIL...>::value)>`] | Nested trait declaration for `UsesAllocatorArgT`. | xref:bsl/variant/2conversion-0b.adoc[`operator BloombergLP::bslmf::NestedTraitDeclaration<variant, UsesBslmaAllocator, (BloombergLP::bslstl::Variant_UsesBslmaAllocatorAny<t_HEAD, t_TAIL...>::value)>`] | Nested trait declaration for `UsesBslmaAllocator`. |=== == Friends [cols="1,4"] |=== | Name| Description | `xref:BloombergLP/bslstl/Variant_Base.adoc[BloombergLP::bslstl::Variant_Base]` | Define the data representation and special member functions of `bsl::variant`. |=== == Non-Member Functions [cols="1,4"] |=== | Name| Description | xref:bsl/get-002.adoc[`get`] | See the first `get` overload above. | xref:bsl/get-035.adoc[`get`] | See the first `get` overload above. | xref:bsl/get-06.adoc[`get`] | See the first `get` overload above. | xref:bsl/get-0b5.adoc[`get`] | Return a reference to the alternative at index `t_INDEX` in `obj`. | xref:bsl/get-0e3.adoc[`get`] | See the first `get` overload above. | xref:bsl/get-0e6.adoc[`get`] | See the first `get` overload above. | xref:bsl/get-0ea.adoc[`get`] | Return a reference to the alternative of type `t_TYPE` in `obj`. | xref:bsl/get-0ee.adoc[`get`] | See the first `get` overload above. | xref:bsl/get_if-06.adoc[`get_if`] | Return a pointer to the `t_TYPE` alternative in `obj` if active. | xref:bsl/get_if-09.adoc[`get_if`] | Return a pointer to the `t_TYPE` alternative in `obj` if active. | xref:bsl/get_if-0a.adoc[`get_if`] | Return a pointer to the alternative at index `t_INDEX`, or null. | xref:bsl/get_if-0d.adoc[`get_if`] | Return a pointer to the alternative at index `t_INDEX` in `obj`, or null. | xref:bsl/holds_alternative.adoc[`holds_alternative`] | Return `true` if `obj` currently holds the `t_TYPE` alternative. | xref:bsl/operator_not_eq-023.adoc[`operator!=`] | Return `true` if `lhs` and `rhs` are not equal. | xref:bsl/operator_lt-01d.adoc[`operator<`] | Return `true` if `lhs` is less than `rhs`. | xref:bsl/operator_le-00.adoc[`operator<=`] | Return `true` if `lhs` is less than or equal to `rhs`. | xref:bsl/operator_3way-09.adoc[`operator<=>`] | Return the three‐way comparison result of `lhs` and `rhs`. | xref:bsl/operator_eq-058.adoc[`operator==`] | Return `true` if `lhs` and `rhs` are equal. | xref:bsl/operator_gt-014.adoc[`operator>`] | Return `true` if `lhs` is greater than `rhs`. | xref:bsl/operator_ge-07a.adoc[`operator>=`] | Return `true` if `lhs` is greater than or equal to `rhs`. | xref:bsl/swap-0f5.adoc[`swap`] | Efficiently exchange the values of the specified `lhs` and `rhs` objects. |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#