[#BloombergLP-bdlb-VariantImp] = xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bdlb.adoc[bdlb]::VariantImp :relfileprefix: ../../ :mrdocs: This class provides the implementation of `Variant` (except for the creators) given a list of template parameter `TYPES`. == Synopsis Declared in `<bdlb_variant.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- 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 [cols="1,4"] |=== | Name| Description | `VariantImp_Traits<TYPES>::BaseType` | |=== == Member Functions [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bdlb/VariantImp/2constructor-0f.adoc[`VariantImp`] [.small]#[constructor]# | Create a variant object in the unset state that uses the currently installed default allocator to supply memory. | xref:BloombergLP/bdlb/VariantImp/2constructor-080.adoc[`VariantImp`] [.small]#[constructor]# | Create a variant by moving from `original`. | xref:BloombergLP/bdlb/VariantImp/2constructor-088.adoc[`VariantImp`] [.small]#[constructor]# | Create a variant from `valueOrAllocator`. | xref:BloombergLP/bdlb/VariantImp/2constructor-0a.adoc[`VariantImp`] [.small]#[constructor]# | Create a variant by moving from the specified `value`. | xref:BloombergLP/bdlb/VariantImp/2constructor-08a3.adoc[`VariantImp`] [.small]#[constructor]# | Create a variant holding `value` using `basicAllocator`. | xref:BloombergLP/bdlb/VariantImp/2constructor-08a4.adoc[`VariantImp`] [.small]#[constructor]# | Create a variant by moving from `original` using `basicAllocator`. | xref:BloombergLP/bdlb/VariantImp/2constructor-0c.adoc[`VariantImp`] [.small]#[constructor]# | Create a variant with the type and value of `original`. | xref:BloombergLP/bdlb/VariantImp/2constructor-0e.adoc[`VariantImp`] [.small]#[constructor]# | Create a variant holding `value` using `basicAllocator`. | xref:BloombergLP/bdlb/VariantImp/2destructor.adoc[`~VariantImp`] [.small]#[destructor]# | Destroy this variant object, invoking the destructor of the type of object contained (if any) on the value of that type. | xref:BloombergLP/bdlb/VariantImp/operator_assign-00.adoc[`operator=`] | Assign the type and value of `rhs` to this object. | xref:BloombergLP/bdlb/VariantImp/operator_assign-02.adoc[`operator=`] | Assign the type and value of `rhs` to this object. | xref:BloombergLP/bdlb/VariantImp/operator_assign-0e.adoc[`operator=`] | Assign the specified `TYPE` `value` to this object. | xref:BloombergLP/bdlb/VariantImp/operator_assign-09.adoc[`operator=`] | Assign the specified `TYPE` `value` to this object. | xref:BloombergLP/bdlb/VariantImp/apply-0ec.adoc[`apply`] | Apply `visitor` to the held value of this modifiable variant. | xref:BloombergLP/bdlb/VariantImp/apply-075b.adoc[`apply`] | Apply the specified `visitor` to this modifiable variant by passing the value this variant currently holds to the `visitor` object's `operator()`. | xref:BloombergLP/bdlb/VariantImp/apply-073.adoc[`apply`] | Apply `visitor` to the held value and return its result. | xref:BloombergLP/bdlb/VariantImp/apply-05.adoc[`apply`] | Apply `visitor` to the held value of this variant. | xref:BloombergLP/bdlb/VariantImp/apply-034.adoc[`apply`] | Apply `visitor` to the held value of this modifiable variant. | xref:BloombergLP/bdlb/VariantImp/apply-0b.adoc[`apply`] | Apply the specified `visitor` to this modifiable variant by passing the value this variant currently holds to the `visitor` object's `operator()`. | xref:BloombergLP/bdlb/VariantImp/apply-00.adoc[`apply`] | Apply `visitor` to the held value and return its result. | xref:BloombergLP/bdlb/VariantImp/apply-06b.adoc[`apply`] | Apply `visitor` to the held value of this variant. | xref:BloombergLP/bdlb/VariantImp/apply-02f.adoc[`apply`] | Apply `visitor` to the held `TYPE` value of this modifiable variant. | xref:BloombergLP/bdlb/VariantImp/apply-0f6.adoc[`apply`] | Apply `visitor` to the held value and return `RET_TYPE`. | xref:BloombergLP/bdlb/VariantImp/apply-062.adoc[`apply`] | Same as the preceding overload, but for a `const` visitor. | xref:BloombergLP/bdlb/VariantImp/apply-0a.adoc[`apply`] | Apply `visitor` to the held value and return `RET_TYPE`. | xref:BloombergLP/bdlb/VariantImp/apply-08.adoc[`apply`] | Apply `visitor` to the held `TYPE` value of this modifiable variant. | xref:BloombergLP/bdlb/VariantImp/apply-06a.adoc[`apply`] | Apply `visitor` to the held `TYPE` value of this modifiable variant. | xref:BloombergLP/bdlb/VariantImp/apply-0e2.adoc[`apply`] | Apply `visitor` to the held `TYPE` value of this variant. | xref:BloombergLP/bdlb/VariantImp/apply-01.adoc[`apply`] | Apply `visitor` to the held `TYPE` value of this variant. | xref:BloombergLP/bdlb/VariantImp/apply-021.adoc[`apply`] | Apply `visitor` to the held `TYPE` value of this modifiable variant. | xref:BloombergLP/bdlb/VariantImp/apply-0df.adoc[`apply`] | Apply `visitor` to the held `TYPE` value of this modifiable variant. | xref:BloombergLP/bdlb/VariantImp/apply-075f.adoc[`apply`] | Apply `visitor` to the held `TYPE` value of this variant. | xref:BloombergLP/bdlb/VariantImp/apply-0d9.adoc[`apply`] | Apply `visitor` to the held `TYPE` value of this variant. | xref:BloombergLP/bdlb/VariantImp/apply-028.adoc[`apply`] | Apply `visitor` to the held `TYPE` value of this modifiable variant. | xref:BloombergLP/bdlb/VariantImp/apply-0e3.adoc[`apply`] | Apply `visitor` to the held `TYPE` value of this variant. | xref:BloombergLP/bdlb/VariantImp/apply-0fc.adoc[`apply`] | Same as the preceding overload, but for a `const` visitor. | xref:BloombergLP/bdlb/VariantImp/apply-03c.adoc[`apply`] | Apply `visitor` to the held `TYPE` value of this variant. | xref:BloombergLP/bdlb/VariantImp/applyRaw-026.adoc[`applyRaw`] | Apply `visitor` to the held `TYPE` value of this modifiable variant. | xref:BloombergLP/bdlb/VariantImp/applyRaw-027.adoc[`applyRaw`] | Apply `visitor` to the held `TYPE` value of this modifiable variant. | xref:BloombergLP/bdlb/VariantImp/applyRaw-0b8.adoc[`applyRaw`] | Apply `visitor` to the held value and return `RET_TYPE`. | xref:BloombergLP/bdlb/VariantImp/applyRaw-086.adoc[`applyRaw`] | Apply `visitor` to the held value of this variant. | xref:BloombergLP/bdlb/VariantImp/applyRaw-01.adoc[`applyRaw`] | Apply `visitor` to the held `TYPE` value of this modifiable variant. | xref:BloombergLP/bdlb/VariantImp/applyRaw-0a.adoc[`applyRaw`] | Apply `visitor` to the held `TYPE` value of this modifiable variant. | xref:BloombergLP/bdlb/VariantImp/applyRaw-0c9.adoc[`applyRaw`] | Apply `visitor` to the held value and return its result. | xref:BloombergLP/bdlb/VariantImp/applyRaw-088.adoc[`applyRaw`] | Apply `visitor` to the held value of this variant. | xref:BloombergLP/bdlb/VariantImp/applyRaw-0c1.adoc[`applyRaw`] | Apply `visitor` to the held alternative without validity checks. | xref:BloombergLP/bdlb/VariantImp/applyRaw-0bc.adoc[`applyRaw`] | Apply `visitor` to the held value and return `RET_TYPE`. | xref:BloombergLP/bdlb/VariantImp/applyRaw-0c8.adoc[`applyRaw`] | Apply a const `visitor` to the held alternative without checks. | xref:BloombergLP/bdlb/VariantImp/applyRaw-06.adoc[`applyRaw`] | Same as the preceding overload, but for a `const` visitor. | xref:BloombergLP/bdlb/VariantImp/assign-06.adoc[`assign`] | Assign the specified `TYPE` `value` to this object. | xref:BloombergLP/bdlb/VariantImp/assign-0b.adoc[`assign`] | Assign the specified `TYPE` `value` to this object. | xref:BloombergLP/bdlb/VariantImp/assignTo.adoc[`assignTo`] | Assign `value` converted to `TYPE` to this object. | xref:BloombergLP/bdlb/VariantImp/bdexStreamIn.adoc[`bdexStreamIn`] | DEPRECATED: Do not use. | xref:BloombergLP/bdlb/VariantImp/bdexStreamOut.adoc[`bdexStreamOut`] | DEPRECATED: Do not use. | xref:BloombergLP/bdlb/VariantImp/createInPlace.adoc[`createInPlace`] | Emplace a `TYPE` instance constructed from `arguments`. | xref:BloombergLP/bdlb/VariantImp/is.adoc[`is`] | Return whether this variant currently holds a `TYPE` value. | xref:BloombergLP/bdlb/VariantImp/isUnset.adoc[`isUnset`] | Return whether this variant currently holds no value. | xref:BloombergLP/bdlb/VariantImp/maxSupportedBdexVersion.adoc[`maxSupportedBdexVersion`] | DEPRECATED: Do not use. | xref:BloombergLP/bdlb/VariantImp/print.adoc[`print`] | Format this object to the specified output `stream`. | xref:BloombergLP/bdlb/VariantImp/reset.adoc[`reset`] | Destroy the current value held by this variant (if any), and reset this variant to the unset state. | xref:BloombergLP/bdlb/VariantImp/swap.adoc[`swap`] | Swap the value of this object with `other`. | xref:BloombergLP/bdlb/VariantImp/the-0e.adoc[`the`] | Return a modifiable reference to the held `TYPE` value. | xref:BloombergLP/bdlb/VariantImp/the-0a.adoc[`the`] | Return a non‐modifiable reference to the held `TYPE` value. | xref:BloombergLP/bdlb/VariantImp/typeIndex.adoc[`typeIndex`] | Return the 1‐based index of the held type, or 0 if unset. | xref:BloombergLP/bdlb/VariantImp/typeInfo.adoc[`typeInfo`] | Return `typeid(void)`. | xref:BloombergLP/bdlb/VariantImp/2conversion-0e.adoc[`operator BloombergLP::bslmf::NestedTraitDeclaration<VariantImp, HasPrintMethod>`] | Nested trait declaration for `bdlb::HasPrintMethod`. | xref:BloombergLP/bdlb/VariantImp/2conversion-02.adoc[`operator BloombergLP::bslmf::NestedTraitDeclaration<VariantImp, IsBitwiseCopyable, Traits::k_VARIANT_IS_BITWISE_COPYABLE>`] | Nested trait declaration for `bslmf::IsBitwiseCopyable`. | xref:BloombergLP/bdlb/VariantImp/2conversion-05.adoc[`operator BloombergLP::bslmf::NestedTraitDeclaration<VariantImp, IsBitwiseMoveable, Traits::k_VARIANT_IS_BITWISE_MOVEABLE>`] | Nested trait declaration for `bslmf::IsBitwiseMoveable`. | xref:BloombergLP/bdlb/VariantImp/2conversion-04.adoc[`operator BloombergLP::bslmf::NestedTraitDeclaration<VariantImp, UsesBslmaAllocator, Traits::k_VARIANT_USES_BSLMA_ALLOCATOR>`] | Nested trait declaration for `bslma::UsesBslmaAllocator`. |=== == Non-Member Functions [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bdlb/operator_not_eq-045.adoc[`operator!=`] | Return whether `lhs` and `rhs` do not have the same value. | xref:BloombergLP/bdlb/operator_eq-0101.adoc[`operator==`] | Grant the equality comparison operator access to this class's private members. | xref:BloombergLP/bdlb/operator_eq-0fc.adoc[`operator==`] | Return whether `lhs` and `rhs` have the same value. | xref:BloombergLP/bdlb/swap-04.adoc[`swap`] | Swap the values of the specified `a` and `b` objects. |=== == Derived Classes [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bdlb/Variant.adoc[`Variant`] | Discriminated union that holds a value of one of up to 20 alternative types. | xref:BloombergLP/bdlb/Variant10.adoc[`Variant10`] | Fixed‐arity specialization of `Variant` for 10 types. | xref:BloombergLP/bdlb/Variant11.adoc[`Variant11`] | Fixed‐arity specialization of `Variant` for 11 types. | xref:BloombergLP/bdlb/Variant12.adoc[`Variant12`] | Fixed‐arity specialization of `Variant` for 12 types. | xref:BloombergLP/bdlb/Variant13.adoc[`Variant13`] | Fixed‐arity specialization of `Variant` for 13 types. | xref:BloombergLP/bdlb/Variant14.adoc[`Variant14`] | Fixed‐arity specialization of `Variant` for 14 types. | xref:BloombergLP/bdlb/Variant15.adoc[`Variant15`] | Fixed‐arity specialization of `Variant` for 15 types. | xref:BloombergLP/bdlb/Variant16.adoc[`Variant16`] | Fixed‐arity specialization of `Variant` for 16 types. | xref:BloombergLP/bdlb/Variant17.adoc[`Variant17`] | Fixed‐arity specialization of `Variant` for 17 types. | xref:BloombergLP/bdlb/Variant18.adoc[`Variant18`] | Fixed‐arity specialization of `Variant` for 18 types. | xref:BloombergLP/bdlb/Variant19.adoc[`Variant19`] | Fixed‐arity specialization of `Variant` for 19 types. | xref:BloombergLP/bdlb/Variant2.adoc[`Variant2`] | Fixed‐arity specialization of `Variant` for 2 types. | xref:BloombergLP/bdlb/Variant3.adoc[`Variant3`] | Fixed‐arity specialization of `Variant` for 3 types. | xref:BloombergLP/bdlb/Variant4.adoc[`Variant4`] | Fixed‐arity specialization of `Variant` for 4 types. | xref:BloombergLP/bdlb/Variant5.adoc[`Variant5`] | Fixed‐arity specialization of `Variant` for 5 types. | xref:BloombergLP/bdlb/Variant6.adoc[`Variant6`] | Fixed‐arity specialization of `Variant` for 6 types. | xref:BloombergLP/bdlb/Variant7.adoc[`Variant7`] | Fixed‐arity specialization of `Variant` for 7 types. | xref:BloombergLP/bdlb/Variant8.adoc[`Variant8`] | Fixed‐arity specialization of `Variant` for 8 types. | xref:BloombergLP/bdlb/Variant9.adoc[`Variant9`] | Fixed‐arity specialization of `Variant` for 9 types. |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#