[#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`&period;

== Synopsis

Declared in `&lt;bdlb&lowbar;variant&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class TYPES&gt;
class VariantImp
    : public VariantImp&lowbar;Traits&lt;TYPES&gt;::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&period; A precise operational definition of when two instances have the same value can be found in the description of `operator&equals;&equals;` for the class&period; This class is _exception_ _neutral_ with no guarantee of rollback&colon; if an exception is thrown during the invocation of a method on a pre&hyphen;existing instance, the object is left in a valid state, but its value is undefined&period; In no event is memory leaked&period; Finally, _aliasing_ (e&period;g&period;, using all or part of an object as both source and destination) is supported in all cases&period;

If any of the types in the list of `TYPES` does not support `operator&equals;&equals;`, or any of the value&hyphen;semantic operations mentioned above, then this variant also does not support that operation and attempts to invoke it will trigger a compilation diagnostic&period;

== Base Classes

[cols="1,4"]
|===
| Name| Description
| `VariantImp&lowbar;Traits&lt;TYPES&gt;::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&period;
| xref:BloombergLP/bdlb/VariantImp/2constructor-080.adoc[`VariantImp`]         [.small]#[constructor]#
| Create a variant by moving from `original`&period;
| xref:BloombergLP/bdlb/VariantImp/2constructor-088.adoc[`VariantImp`]         [.small]#[constructor]#
| Create a variant from `valueOrAllocator`&period;
| xref:BloombergLP/bdlb/VariantImp/2constructor-0a.adoc[`VariantImp`]         [.small]#[constructor]#
| Create a variant by moving from the specified `value`&period;
| xref:BloombergLP/bdlb/VariantImp/2constructor-08a3.adoc[`VariantImp`]         [.small]#[constructor]#
| Create a variant holding `value` using `basicAllocator`&period;
| xref:BloombergLP/bdlb/VariantImp/2constructor-08a4.adoc[`VariantImp`]         [.small]#[constructor]#
| Create a variant by moving from `original` using `basicAllocator`&period;
| xref:BloombergLP/bdlb/VariantImp/2constructor-0c.adoc[`VariantImp`]         [.small]#[constructor]#
| Create a variant with the type and value of `original`&period;
| xref:BloombergLP/bdlb/VariantImp/2constructor-0e.adoc[`VariantImp`]         [.small]#[constructor]#
| Create a variant holding `value` using `basicAllocator`&period;
| xref:BloombergLP/bdlb/VariantImp/2destructor.adoc[`&#126;VariantImp`] [.small]#[destructor]#
| Destroy this variant object, invoking the destructor of the type of object contained (if any) on the value of that type&period;
| xref:BloombergLP/bdlb/VariantImp/operator_assign-00.adoc[`operator&equals;`] 
| Assign the type and value of `rhs` to this object&period;
| xref:BloombergLP/bdlb/VariantImp/operator_assign-02.adoc[`operator&equals;`] 
| Assign the type and value of `rhs` to this object&period;
| xref:BloombergLP/bdlb/VariantImp/operator_assign-0e.adoc[`operator&equals;`] 
| Assign the specified `TYPE` `value` to this object&period;
| xref:BloombergLP/bdlb/VariantImp/operator_assign-09.adoc[`operator&equals;`] 
| Assign the specified `TYPE` `value` to this object&period;
| xref:BloombergLP/bdlb/VariantImp/apply-0ec.adoc[`apply`] 
| Apply `visitor` to the held value of this modifiable variant&period;
| 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&apos;s `operator()`&period;
| xref:BloombergLP/bdlb/VariantImp/apply-073.adoc[`apply`] 
| Apply `visitor` to the held value and return its result&period;
| xref:BloombergLP/bdlb/VariantImp/apply-05.adoc[`apply`] 
| Apply `visitor` to the held value of this variant&period;
| xref:BloombergLP/bdlb/VariantImp/apply-034.adoc[`apply`] 
| Apply `visitor` to the held value of this modifiable variant&period;
| 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&apos;s `operator()`&period;
| xref:BloombergLP/bdlb/VariantImp/apply-00.adoc[`apply`] 
| Apply `visitor` to the held value and return its result&period;
| xref:BloombergLP/bdlb/VariantImp/apply-06b.adoc[`apply`] 
| Apply `visitor` to the held value of this variant&period;
| xref:BloombergLP/bdlb/VariantImp/apply-02f.adoc[`apply`] 
| Apply `visitor` to the held `TYPE` value of this modifiable variant&period;
| xref:BloombergLP/bdlb/VariantImp/apply-0f6.adoc[`apply`] 
| Apply `visitor` to the held value and return `RET&lowbar;TYPE`&period;
| xref:BloombergLP/bdlb/VariantImp/apply-062.adoc[`apply`] 
| Same as the preceding overload, but for a `const` visitor&period;
| xref:BloombergLP/bdlb/VariantImp/apply-0a.adoc[`apply`] 
| Apply `visitor` to the held value and return `RET&lowbar;TYPE`&period;
| xref:BloombergLP/bdlb/VariantImp/apply-08.adoc[`apply`] 
| Apply `visitor` to the held `TYPE` value of this modifiable variant&period;
| xref:BloombergLP/bdlb/VariantImp/apply-06a.adoc[`apply`] 
| Apply `visitor` to the held `TYPE` value of this modifiable variant&period;
| xref:BloombergLP/bdlb/VariantImp/apply-0e2.adoc[`apply`] 
| Apply `visitor` to the held `TYPE` value of this variant&period;
| xref:BloombergLP/bdlb/VariantImp/apply-01.adoc[`apply`] 
| Apply `visitor` to the held `TYPE` value of this variant&period;
| xref:BloombergLP/bdlb/VariantImp/apply-021.adoc[`apply`] 
| Apply `visitor` to the held `TYPE` value of this modifiable variant&period;
| xref:BloombergLP/bdlb/VariantImp/apply-0df.adoc[`apply`] 
| Apply `visitor` to the held `TYPE` value of this modifiable variant&period;
| xref:BloombergLP/bdlb/VariantImp/apply-075f.adoc[`apply`] 
| Apply `visitor` to the held `TYPE` value of this variant&period;
| xref:BloombergLP/bdlb/VariantImp/apply-0d9.adoc[`apply`] 
| Apply `visitor` to the held `TYPE` value of this variant&period;
| xref:BloombergLP/bdlb/VariantImp/apply-028.adoc[`apply`] 
| Apply `visitor` to the held `TYPE` value of this modifiable variant&period;
| xref:BloombergLP/bdlb/VariantImp/apply-0e3.adoc[`apply`] 
| Apply `visitor` to the held `TYPE` value of this variant&period;
| xref:BloombergLP/bdlb/VariantImp/apply-0fc.adoc[`apply`] 
| Same as the preceding overload, but for a `const` visitor&period;
| xref:BloombergLP/bdlb/VariantImp/apply-03c.adoc[`apply`] 
| Apply `visitor` to the held `TYPE` value of this variant&period;
| xref:BloombergLP/bdlb/VariantImp/applyRaw-026.adoc[`applyRaw`] 
| Apply `visitor` to the held `TYPE` value of this modifiable variant&period;
| xref:BloombergLP/bdlb/VariantImp/applyRaw-027.adoc[`applyRaw`] 
| Apply `visitor` to the held `TYPE` value of this modifiable variant&period;
| xref:BloombergLP/bdlb/VariantImp/applyRaw-0b8.adoc[`applyRaw`] 
| Apply `visitor` to the held value and return `RET&lowbar;TYPE`&period;
| xref:BloombergLP/bdlb/VariantImp/applyRaw-086.adoc[`applyRaw`] 
| Apply `visitor` to the held value of this variant&period;
| xref:BloombergLP/bdlb/VariantImp/applyRaw-01.adoc[`applyRaw`] 
| Apply `visitor` to the held `TYPE` value of this modifiable variant&period;
| xref:BloombergLP/bdlb/VariantImp/applyRaw-0a.adoc[`applyRaw`] 
| Apply `visitor` to the held `TYPE` value of this modifiable variant&period;
| xref:BloombergLP/bdlb/VariantImp/applyRaw-0c9.adoc[`applyRaw`] 
| Apply `visitor` to the held value and return its result&period;
| xref:BloombergLP/bdlb/VariantImp/applyRaw-088.adoc[`applyRaw`] 
| Apply `visitor` to the held value of this variant&period;
| xref:BloombergLP/bdlb/VariantImp/applyRaw-0c1.adoc[`applyRaw`] 
| Apply `visitor` to the held alternative without validity checks&period;
| xref:BloombergLP/bdlb/VariantImp/applyRaw-0bc.adoc[`applyRaw`] 
| Apply `visitor` to the held value and return `RET&lowbar;TYPE`&period;
| xref:BloombergLP/bdlb/VariantImp/applyRaw-0c8.adoc[`applyRaw`] 
| Apply a const `visitor` to the held alternative without checks&period;
| xref:BloombergLP/bdlb/VariantImp/applyRaw-06.adoc[`applyRaw`] 
| Same as the preceding overload, but for a `const` visitor&period;
| xref:BloombergLP/bdlb/VariantImp/assign-06.adoc[`assign`] 
| Assign the specified `TYPE` `value` to this object&period;
| xref:BloombergLP/bdlb/VariantImp/assign-0b.adoc[`assign`] 
| Assign the specified `TYPE` `value` to this object&period;
| xref:BloombergLP/bdlb/VariantImp/assignTo.adoc[`assignTo`] 
| Assign `value` converted to `TYPE` to this object&period;
| xref:BloombergLP/bdlb/VariantImp/bdexStreamIn.adoc[`bdexStreamIn`] 
| DEPRECATED&colon; Do not use&period;
| xref:BloombergLP/bdlb/VariantImp/bdexStreamOut.adoc[`bdexStreamOut`] 
| DEPRECATED&colon; Do not use&period;
| xref:BloombergLP/bdlb/VariantImp/createInPlace.adoc[`createInPlace`] 
| Emplace a `TYPE` instance constructed from `arguments`&period;
| xref:BloombergLP/bdlb/VariantImp/is.adoc[`is`] 
| Return whether this variant currently holds a `TYPE` value&period;
| xref:BloombergLP/bdlb/VariantImp/isUnset.adoc[`isUnset`] 
| Return whether this variant currently holds no value&period;
| xref:BloombergLP/bdlb/VariantImp/maxSupportedBdexVersion.adoc[`maxSupportedBdexVersion`] 
| DEPRECATED&colon; Do not use&period;
| xref:BloombergLP/bdlb/VariantImp/print.adoc[`print`] 
| Format this object to the specified output `stream`&period;
| 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&period;
| xref:BloombergLP/bdlb/VariantImp/swap.adoc[`swap`] 
| Swap the value of this object with `other`&period;
| xref:BloombergLP/bdlb/VariantImp/the-0e.adoc[`the`] 
| Return a modifiable reference to the held `TYPE` value&period;
| xref:BloombergLP/bdlb/VariantImp/the-0a.adoc[`the`] 
| Return a non&hyphen;modifiable reference to the held `TYPE` value&period;
| xref:BloombergLP/bdlb/VariantImp/typeIndex.adoc[`typeIndex`] 
| Return the 1&hyphen;based index of the held type, or 0 if unset&period;
| xref:BloombergLP/bdlb/VariantImp/typeInfo.adoc[`typeInfo`] 
| Return `typeid(void)`&period;
| xref:BloombergLP/bdlb/VariantImp/2conversion-0e.adoc[`operator BloombergLP::bslmf::NestedTraitDeclaration&lt;VariantImp, HasPrintMethod&gt;`] 
| Nested trait declaration for `bdlb&colon;&colon;HasPrintMethod`&period;
| xref:BloombergLP/bdlb/VariantImp/2conversion-02.adoc[`operator BloombergLP::bslmf::NestedTraitDeclaration&lt;VariantImp, IsBitwiseCopyable, Traits&colon;&colon;k&lowbar;VARIANT&lowbar;IS&lowbar;BITWISE&lowbar;COPYABLE&gt;`] 
| Nested trait declaration for `bslmf&colon;&colon;IsBitwiseCopyable`&period;
| xref:BloombergLP/bdlb/VariantImp/2conversion-05.adoc[`operator BloombergLP::bslmf::NestedTraitDeclaration&lt;VariantImp, IsBitwiseMoveable, Traits&colon;&colon;k&lowbar;VARIANT&lowbar;IS&lowbar;BITWISE&lowbar;MOVEABLE&gt;`] 
| Nested trait declaration for `bslmf&colon;&colon;IsBitwiseMoveable`&period;
| xref:BloombergLP/bdlb/VariantImp/2conversion-04.adoc[`operator BloombergLP::bslmf::NestedTraitDeclaration&lt;VariantImp, UsesBslmaAllocator, Traits&colon;&colon;k&lowbar;VARIANT&lowbar;USES&lowbar;BSLMA&lowbar;ALLOCATOR&gt;`] 
| Nested trait declaration for `bslma&colon;&colon;UsesBslmaAllocator`&period;
|===


== Non-Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bdlb/operator_not_eq-045.adoc[`operator!&equals;`]
| Return whether `lhs` and `rhs` do not have the same value&period;
| xref:BloombergLP/bdlb/operator_eq-0101.adoc[`operator&equals;&equals;`]
| Grant the equality comparison operator access to this class&apos;s private members&period;
| xref:BloombergLP/bdlb/operator_eq-0fc.adoc[`operator&equals;&equals;`]
| Return whether `lhs` and `rhs` have the same value&period;
| xref:BloombergLP/bdlb/swap-04.adoc[`swap`]
| Swap the values of the specified `a` and `b` objects&period;
|===

== 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&period;
| xref:BloombergLP/bdlb/Variant10.adoc[`Variant10`] 
| Fixed&hyphen;arity specialization of `Variant` for 10 types&period;
| xref:BloombergLP/bdlb/Variant11.adoc[`Variant11`] 
| Fixed&hyphen;arity specialization of `Variant` for 11 types&period;
| xref:BloombergLP/bdlb/Variant12.adoc[`Variant12`] 
| Fixed&hyphen;arity specialization of `Variant` for 12 types&period;
| xref:BloombergLP/bdlb/Variant13.adoc[`Variant13`] 
| Fixed&hyphen;arity specialization of `Variant` for 13 types&period;
| xref:BloombergLP/bdlb/Variant14.adoc[`Variant14`] 
| Fixed&hyphen;arity specialization of `Variant` for 14 types&period;
| xref:BloombergLP/bdlb/Variant15.adoc[`Variant15`] 
| Fixed&hyphen;arity specialization of `Variant` for 15 types&period;
| xref:BloombergLP/bdlb/Variant16.adoc[`Variant16`] 
| Fixed&hyphen;arity specialization of `Variant` for 16 types&period;
| xref:BloombergLP/bdlb/Variant17.adoc[`Variant17`] 
| Fixed&hyphen;arity specialization of `Variant` for 17 types&period;
| xref:BloombergLP/bdlb/Variant18.adoc[`Variant18`] 
| Fixed&hyphen;arity specialization of `Variant` for 18 types&period;
| xref:BloombergLP/bdlb/Variant19.adoc[`Variant19`] 
| Fixed&hyphen;arity specialization of `Variant` for 19 types&period;
| xref:BloombergLP/bdlb/Variant2.adoc[`Variant2`] 
| Fixed&hyphen;arity specialization of `Variant` for 2 types&period;
| xref:BloombergLP/bdlb/Variant3.adoc[`Variant3`] 
| Fixed&hyphen;arity specialization of `Variant` for 3 types&period;
| xref:BloombergLP/bdlb/Variant4.adoc[`Variant4`] 
| Fixed&hyphen;arity specialization of `Variant` for 4 types&period;
| xref:BloombergLP/bdlb/Variant5.adoc[`Variant5`] 
| Fixed&hyphen;arity specialization of `Variant` for 5 types&period;
| xref:BloombergLP/bdlb/Variant6.adoc[`Variant6`] 
| Fixed&hyphen;arity specialization of `Variant` for 6 types&period;
| xref:BloombergLP/bdlb/Variant7.adoc[`Variant7`] 
| Fixed&hyphen;arity specialization of `Variant` for 7 types&period;
| xref:BloombergLP/bdlb/Variant8.adoc[`Variant8`] 
| Fixed&hyphen;arity specialization of `Variant` for 8 types&period;
| xref:BloombergLP/bdlb/Variant9.adoc[`Variant9`] 
| Fixed&hyphen;arity specialization of `Variant` for 9 types&period;
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
