This class provides the implementation of Variant (except for the creators) given a list of template parameter TYPES.

Synopsis

Declared in <bdlb_variant.h>

template<class TYPES>
class VariantImp
    : public VariantImp_Traits<TYPES>::BaseType

Description

More generally, if each of the types in the list of TYPES is value semantic, then this class also supports a complete set of value semantic operations, including copy construction, assignment, equality comparison, and ostream printing. A precise operational definition of when two instances have the same value can be found in the description of operator== for the class. This class is exception neutral with no guarantee of rollback: if an exception is thrown during the invocation of a method on a pre‐existing instance, the object is left in a valid state, but its value is undefined. In no event is memory leaked. Finally, aliasing (e.g., using all or part of an object as both source and destination) is supported in all cases.

If any of the types in the list of TYPES does not support operator==, or any of the value‐semantic operations mentioned above, then this variant also does not support that operation and attempts to invoke it will trigger a compilation diagnostic.

Base Classes

Name

Description

VariantImp_Traits<TYPES>::BaseType

Member Functions

Name

Description

VariantImp [constructor]

Create a variant object in the unset state that uses the currently installed default allocator to supply memory.

VariantImp [constructor]

Create a variant by moving from original.

VariantImp [constructor]

Create a variant from valueOrAllocator.

VariantImp [constructor]

Create a variant by moving from the specified value.

VariantImp [constructor]

Create a variant holding value using basicAllocator.

VariantImp [constructor]

Create a variant by moving from original using basicAllocator.

VariantImp [constructor]

Create a variant with the type and value of original.

VariantImp [constructor]

Create a variant holding value using basicAllocator.

~VariantImp [destructor]

Destroy this variant object, invoking the destructor of the type of object contained (if any) on the value of that type.

operator=

Assign the type and value of rhs to this object.

operator=

Assign the type and value of rhs to this object.

operator=

Assign the specified TYPE value to this object.

operator=

Assign the specified TYPE value to this object.

apply

Apply visitor to the held value of this modifiable variant.

apply

Apply the specified visitor to this modifiable variant by passing the value this variant currently holds to the visitor object's operator().

apply

Apply visitor to the held value and return its result.

apply

Apply visitor to the held value of this variant.

apply

Apply visitor to the held value of this modifiable variant.

apply

Apply the specified visitor to this modifiable variant by passing the value this variant currently holds to the visitor object's operator().

apply

Apply visitor to the held value and return its result.

apply

Apply visitor to the held value of this variant.

apply

Apply visitor to the held TYPE value of this modifiable variant.

apply

Apply visitor to the held value and return RET_TYPE.

apply

Same as the preceding overload, but for a const visitor.

apply

Apply visitor to the held value and return RET_TYPE.

apply

Apply visitor to the held TYPE value of this modifiable variant.

apply

Apply visitor to the held TYPE value of this modifiable variant.

apply

Apply visitor to the held TYPE value of this variant.

apply

Apply visitor to the held TYPE value of this variant.

apply

Apply visitor to the held TYPE value of this modifiable variant.

apply

Apply visitor to the held TYPE value of this modifiable variant.

apply

Apply visitor to the held TYPE value of this variant.

apply

Apply visitor to the held TYPE value of this variant.

apply

Apply visitor to the held TYPE value of this modifiable variant.

apply

Apply visitor to the held TYPE value of this variant.

apply

Same as the preceding overload, but for a const visitor.

apply

Apply visitor to the held TYPE value of this variant.

applyRaw

Apply visitor to the held TYPE value of this modifiable variant.

applyRaw

Apply visitor to the held TYPE value of this modifiable variant.

applyRaw

Apply visitor to the held value and return RET_TYPE.

applyRaw

Apply visitor to the held value of this variant.

applyRaw

Apply visitor to the held TYPE value of this modifiable variant.

applyRaw

Apply visitor to the held TYPE value of this modifiable variant.

applyRaw

Apply visitor to the held value and return its result.

applyRaw

Apply visitor to the held value of this variant.

applyRaw

Apply visitor to the held alternative without validity checks.

applyRaw

Apply visitor to the held value and return RET_TYPE.

applyRaw

Apply a const visitor to the held alternative without checks.

applyRaw

Same as the preceding overload, but for a const visitor.

assign

Assign the specified TYPE value to this object.

assign

Assign the specified TYPE value to this object.

assignTo

Assign value converted to TYPE to this object.

bdexStreamIn

DEPRECATED: Do not use.

bdexStreamOut

DEPRECATED: Do not use.

createInPlace

Emplace a TYPE instance constructed from arguments.

is

Return whether this variant currently holds a TYPE value.

isUnset

Return whether this variant currently holds no value.

maxSupportedBdexVersion

DEPRECATED: Do not use.

print

Format this object to the specified output stream.

reset

Destroy the current value held by this variant (if any), and reset this variant to the unset state.

swap

Swap the value of this object with other.

the

Return a modifiable reference to the held TYPE value.

the

Return a non‐modifiable reference to the held TYPE value.

typeIndex

Return the 1‐based index of the held type, or 0 if unset.

typeInfo

Return typeid(void).

operator BloombergLP::bslmf::NestedTraitDeclaration<VariantImp, HasPrintMethod>

Nested trait declaration for bdlb::HasPrintMethod.

operator BloombergLP::bslmf::NestedTraitDeclaration<VariantImp, IsBitwiseCopyable, Traits::k_VARIANT_IS_BITWISE_COPYABLE>

Nested trait declaration for bslmf::IsBitwiseCopyable.

operator BloombergLP::bslmf::NestedTraitDeclaration<VariantImp, IsBitwiseMoveable, Traits::k_VARIANT_IS_BITWISE_MOVEABLE>

Nested trait declaration for bslmf::IsBitwiseMoveable.

operator BloombergLP::bslmf::NestedTraitDeclaration<VariantImp, UsesBslmaAllocator, Traits::k_VARIANT_USES_BSLMA_ALLOCATOR>

Nested trait declaration for bslma::UsesBslmaAllocator.

Non-Member Functions

Name

Description

operator!=

Return whether lhs and rhs do not have the same value.

operator==

Grant the equality comparison operator access to this class's private members.

operator==

Return whether lhs and rhs have the same value.

swap

Swap the values of the specified a and b objects.

Derived Classes

Name

Description

Variant

Discriminated union that holds a value of one of up to 20 alternative types.

Variant10

Fixed‐arity specialization of Variant for 10 types.

Variant11

Fixed‐arity specialization of Variant for 11 types.

Variant12

Fixed‐arity specialization of Variant for 12 types.

Variant13

Fixed‐arity specialization of Variant for 13 types.

Variant14

Fixed‐arity specialization of Variant for 14 types.

Variant15

Fixed‐arity specialization of Variant for 15 types.

Variant16

Fixed‐arity specialization of Variant for 16 types.

Variant17

Fixed‐arity specialization of Variant for 17 types.

Variant18

Fixed‐arity specialization of Variant for 18 types.

Variant19

Fixed‐arity specialization of Variant for 19 types.

Variant2

Fixed‐arity specialization of Variant for 2 types.

Variant3

Fixed‐arity specialization of Variant for 3 types.

Variant4

Fixed‐arity specialization of Variant for 4 types.

Variant5

Fixed‐arity specialization of Variant for 5 types.

Variant6

Fixed‐arity specialization of Variant for 6 types.

Variant7

Fixed‐arity specialization of Variant for 7 types.

Variant8

Fixed‐arity specialization of Variant for 8 types.

Variant9

Fixed‐arity specialization of Variant for 9 types.

Created with MrDocs