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>

Base Classes

Name

Description

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

Name

Description

NoAlloc

This trivial tag type is used as a dummy when Variant_Base wraps a non‐allocator‐aware type.

Type Aliases

Name

Description

AllocBase

Base class providing allocator support when needed.

MoveUtil

Utility for movable reference operations.

Variant

Corresponding public bsl::variant type.

Variant_Union

Union holding the active alternative objects.

allocator_type

Type alias to the allocator type used by variant.

Member Functions

Name

Description

Variant_Base [constructor]

Constructors

~Variant_Base [destructor]

Destroy this object. The contained value, if any, is destroyed.

operator=

Assignment operators

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.

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.

reset

Destroy the contained value, if any.

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

Nested trait declaration for IsBitwiseMoveable.

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

Nested trait declaration for UsesAllocatorArgT.

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

Nested trait declaration for UsesBslmaAllocator.

Data Members

Name

Description

d_type

Index of the currently active alternative in this variant object, or bsl::variant_npos if the variant is valueless by exception.

d_union

Union holding the alternative object.

Created with MrDocs