[#BloombergLP-bslstl-Variant_Base] = xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bslstl.adoc[bslstl]::Variant_Base :relfileprefix: ../../ :mrdocs: This component‐private struct defines the data representation of `bsl::variant` and contains the implementations of its special member functions (which must be defaulted in `bsl::variant` itself). This class also contains implementations of additional constructors and methods needed for the correct functionality of the `variant` class hierarchy. == Synopsis Declared in `<bslstl_variant.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template< class t_HEAD, class... t_TAIL> struct Variant_Base : xref:BloombergLP/bslstl/Variant_AllocatorBase-0e.adoc[BloombergLP::bslstl::Variant_AllocatorBase<BloombergLP::bslstl::Variant_UsesBslmaAllocatorAny<t_HEAD, t_TAIL...>::value>] ---- == Base Classes [cols="1,4"] |=== | Name| Description | `xref:BloombergLP/bslstl/Variant_AllocatorBase-0e.adoc[BloombergLP::bslstl::Variant_AllocatorBase<BloombergLP::bslstl::Variant_UsesBslmaAllocatorAny<t_HEAD, t_TAIL...>::value>]` | This component‐private struct keeps track of the allocator for a `bsl::variant` object. The primary template is used when the `variant` is not allocator‐aware (because it has no allocator‐aware alternatives). |=== == Types [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bslstl/Variant_Base/NoAlloc.adoc[`NoAlloc`] | This trivial tag type is used as a dummy when `Variant_Base` wraps a non‐allocator‐aware type. |=== == Type Aliases [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bslstl/Variant_Base/AllocBase.adoc[`AllocBase`] | Base class providing allocator support when needed. | xref:BloombergLP/bslstl/Variant_Base/MoveUtil.adoc[`MoveUtil`] | Utility for movable reference operations. | xref:BloombergLP/bslstl/Variant_Base/Variant.adoc[`Variant`] | Corresponding public `bsl::variant` type. | xref:BloombergLP/bslstl/Variant_Base/Variant_Union.adoc[`Variant_Union`] | Union holding the active alternative objects. | xref:BloombergLP/bslstl/Variant_Base/allocator_type.adoc[`allocator_type`] | Type alias to the allocator type used by `variant`. |=== == Member Functions [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bslstl/Variant_Base/2constructor-08d.adoc[`Variant_Base`] [.small]#[constructor]# | Constructors | xref:BloombergLP/bslstl/Variant_Base/2destructor.adoc[`~Variant_Base`] [.small]#[destructor]# | Destroy this object. The contained value, if any, is destroyed. | xref:BloombergLP/bslstl/Variant_Base/operator_assign-06.adoc[`operator=`] | Assignment operators | xref:BloombergLP/bslstl/Variant_Base/baseEmplace.adoc[`baseEmplace`] | Create the alternative with index (template parameter) `t_INDEX` in place, direct‐initialized from the specified `args`. If this `Variant_Base` object already holds a value, that contained value is destroyed before the new object is created. If the alternative is allocator‐aware, it uses the allocator specified upon the construction of this `Variant_Base` object to supply memory; passing an allocator argument to this method results in two allocators being passed to the alternative constructor, resulting in a likely compilation error. Note that if the constructor of the alternative exits via an exception, this object is left in the valueless by exception state. | xref:BloombergLP/bslstl/Variant_AllocatorBase-0e/mechanism.adoc[`mechanism`] | Return a null pointer. Note that this method has the same return type as the allocator‐aware version so that the remainder of the implementation of `bsl::variant` is abstracted with respect to whether or not the specialization is allocator‐aware; this is why both methods return `bslma::Allocator*` instead of `bsl::allocator<char>`. The returned pointer will be ignored (and not dereferenced) when passed to `bslma::ConstructionUtil::construct`. | xref:BloombergLP/bslstl/Variant_Base/reset.adoc[`reset`] | Destroy the contained value, if any. | xref:BloombergLP/bslstl/Variant_Base/2conversion-0e.adoc[`operator BloombergLP::bslmf::NestedTraitDeclaration<Variant_Base, IsBitwiseMoveable, (BloombergLP::bslstl::Variant_IsBitwiseMoveableAll<t_HEAD, t_TAIL...>::value)>`] | Nested trait declaration for `IsBitwiseMoveable`. | xref:BloombergLP/bslstl/Variant_Base/2conversion-03.adoc[`operator BloombergLP::bslmf::NestedTraitDeclaration<Variant_Base, UsesAllocatorArgT, (BloombergLP::bslstl::Variant_UsesBslmaAllocatorAny<t_HEAD, t_TAIL...>::value)>`] | Nested trait declaration for `UsesAllocatorArgT`. | xref:BloombergLP/bslstl/Variant_Base/2conversion-0f.adoc[`operator BloombergLP::bslmf::NestedTraitDeclaration<Variant_Base, UsesBslmaAllocator, (BloombergLP::bslstl::Variant_UsesBslmaAllocatorAny<t_HEAD, t_TAIL...>::value)>`] | Nested trait declaration for `UsesBslmaAllocator`. |=== == Data Members [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bslstl/Variant_Base/d_type.adoc[`d_type`] | Index of the currently active alternative in this variant object, or `bsl::variant_npos` if the variant is valueless by exception. | xref:BloombergLP/bslstl/Variant_Base/d_union.adoc[`d_union`] | Union holding the alternative object. |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#