[#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 object having the type and value of the specified `original` object by moving the contents of `original` to the newly&hyphen;created object&period; The allocator associated with `original` (if any) is propagated for use in the newly&hyphen;created object&period; `original` is left in a valid but unspecified state&period;
| xref:BloombergLP/bdlb/VariantImp/2constructor-088.adoc[`VariantImp`]         [.small]#[constructor]#
| Create a variant object with the specified `valueOrAllocator` that can be either a value of a type that the variant can hold or an allocator to supply memory&period; If `valueOrAllocator` is not a `bslma&colon;&colon;Allocator &ast;`, then the variant will hold the value and type of `valueOrAllocator`, and use the currently installed default allocator to supply memory&period; Otherwise, the variant will be unset and use `valueOrAllocator` to supply memory&period; `TYPE&lowbar;OR&lowbar;ALLOCATOR` must be the same as one of the types that this variant can hold or be convertible to `bslma&colon;&colon;Allocator &ast;`&period; Note that this parameterized constructor is defined instead of two constructors (one taking a `bslma&colon;&colon;Allocator &ast;` and the other not) because template parameter arguments are always a better match than derived&hyphen;to&hyphen;base conversion (a concrete allocator pointer converted to `bslma&colon;&colon;Allocator &ast;`)&period;
| xref:BloombergLP/bdlb/VariantImp/2constructor-08a4.adoc[`VariantImp`]         [.small]#[constructor]#
| Create a variant object having the type and value of the specified `original` object that uses the specified `basicAllocator` to supply memory&period; If `basicAllocator` is 0, the currently installed default allocator is used&period; The contents of `original` are moved to the newly&hyphen;created object with `original` left in a valid but unspecified state&period;
| xref:BloombergLP/bdlb/VariantImp/2constructor-0c.adoc[`VariantImp`]         [.small]#[constructor]#
| Create a variant object having the type and value of the specified `original` variant&period; Optionally specify a `basicAllocator` used to supply memory&period; If `basicAllocator` is 0, the currently installed default allocator is used&period;
| xref:BloombergLP/bdlb/VariantImp/2constructor-0e.adoc[`VariantImp`]         [.small]#[constructor]#
| Create a variant object having the specified `value` of template parameter `TYPE` and that uses the specified `basicAllocator` to supply memory&period; If `basicAllocator` is 0, the currently installed default allocator is used&period; `TYPE` must be the same as one of the types that this variant can hold&period;
| xref:BloombergLP/bdlb/VariantImp/2constructor-0a.adoc[`VariantImp`]         [.small]#[constructor]#
| Create a variant object having the specified `value` of template parameter `TYPE` by moving the contents of `value` to the newly&hyphen;created object&period; Use the currently installed default allocator to supply memory&period; `value` is left in a valid but unspecified state&period; `TYPE` must be the same as one of the types that this variant can hold&period; Note that in C&plus;&plus;11 mode, this method does not participate in overload resolution if it would lead to ambiguity with the move constructor that does not take an allocator (below) or with the constructor taking a `valueOrAllocator` (above)&period;
| xref:BloombergLP/bdlb/VariantImp/2constructor-08a3.adoc[`VariantImp`]         [.small]#[constructor]#
| Create a variant object having the specified `value` of template parameter `TYPE` that uses the specified `basicAllocator` to supply memory&period; If `basicAllocator` is 0, the currently installed default allocator is used&period; The contents of `value` are moved to the newly&hyphen;created object with `value` left in a valid but unspecified state&period; `TYPE` must be the same as one of the types that this variant can hold&period; Note that in C&plus;&plus;11 mode, this method does not participate in overload resolution if it would lead to ambiguity with the move constructor that takes an allocator (below)&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 to this object the type and value currently held by the specified `rhs` object, and return a reference providing modifiable access to this object&period; The value currently held by this variant (if any) is destroyed if that value&apos;s type is not the same as the type held by the `rhs` object&period;
| xref:BloombergLP/bdlb/VariantImp/operator_assign-02.adoc[`operator&equals;`] 
| Assign to this object the type and value currently held by the specified `rhs` object, and return a reference providing modifiable access to this object&period; The contents of `rhs` are either move&hyphen;inserted into or move&hyphen;assigned to this object with `rhs` left in a valid but unspecified state&period;
| xref:BloombergLP/bdlb/VariantImp/operator_assign-0e.adoc[`operator&equals;`] 
| Assign to this object the specified `value` of template parameter `TYPE`, and return a reference providing modifiable access to this object&period; The value currently held by this variant (if any) is destroyed if that value&apos;s type is not the same as `TYPE`&period; `TYPE` must be the same as one of the types that this variant can hold&period;
| xref:BloombergLP/bdlb/VariantImp/operator_assign-09.adoc[`operator&equals;`] 
| Assign to this object the specified `value` of template parameter `TYPE`, and return a reference providing modifiable access to this object&period; The contents of `value` are moved to this object with `value` left in a valid but unspecified state&period; The value currently held by this variant (if any) is destroyed if that value&grave;s type is not the same as `TYPE`&period; `TYPE` must be the same as one of the types that this variant can hold&period; Note that in C&plus;&plus;11 mode, this method does not participate in overload resolution if it would lead to ambiguity with the move&hyphen;assignment operator (below)&period;
| xref:BloombergLP/bdlb/VariantImp/apply-0ec.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()`, and return the value returned by the `visitor`&period; If this variant is unset, a default constructed `bslmf&colon;&colon;Nil` is passed to the `visitor`&period; Note that this method is selected only if the template parameter type `VISITOR` defines a `typedef` of `ResultType` in its public interface&period; Also note that this method is defined inline to work around a Windows compiler bug with SFINAE functions&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; This method does not return a value&period; If this variant is unset, a default constructed `bslmf&colon;&colon;Nil` is passed to the `visitor`&period; Note that this method is selected only if the template parameter type `VISITOR` does not define a `typedef` of `ResultType` in its public interface&period; Also note that this method is defined inline to work around a Windows compiler bug with SFINAE functions&period;
| xref:BloombergLP/bdlb/VariantImp/apply-073.adoc[`apply`] 
| Apply the specified `visitor` to this variant by passing the value this variant currently holds to the `visitor` object&apos;s `operator()`, and return the value returned by the `visitor`&period; If this variant is unset, a default constructed `bslmf&colon;&colon;Nil` is passed to the `visitor`&period; Note that this method is selected only if the template parameter type `VISITOR` defines a `typedef` of `ResultType` in its public interface&period; Also note that this method is defined inline to work around a Windows compiler bug with SFINAE functions&period;
| xref:BloombergLP/bdlb/VariantImp/apply-05.adoc[`apply`] 
| Apply the specified `visitor` to this variant by passing the value this variant currently holds to the `visitor` object&apos;s `operator()`&period; This method does not return a value&period; If this variant is unset, a default constructed `bslmf&colon;&colon;Nil` is passed to the `visitor`&period; Note that this method is selected only if the template parameter type `VISITOR` does not define a `typedef` of `ResultType` in its public interface&period; Also note that this method is defined inline to work around a Windows compiler bug with SFINAE functions&period;
| xref:BloombergLP/bdlb/VariantImp/apply-034.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()`, and return the value returned by the `visitor`&period; If If this variant is unset, a default constructed `bslmf&colon;&colon;Nil` is passed to the `visitor`&period; Note that this method is selected only if the template parameter type `VISITOR` defines a `typedef` of `ResultType` in its public interface&period; Also note that this method is defined inline to work around a Windows compiler bug with SFINAE functions&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; This method does not return a value&period; If this variant is unset, a default constructed `bslmf&colon;&colon;Nil` is passed to the `visitor`&period; Note that this method is selected only if the template parameter type `VISITOR` does not define a `typedef` of `ResultType` in its public interface&period; Also note that this method is defined inline to work around a Windows compiler bug with SFINAE functions&period;
| xref:BloombergLP/bdlb/VariantImp/apply-00.adoc[`apply`] 
| Apply the specified `visitor` to this variant by passing the value this variant currently holds to the `visitor` object&apos;s `operator()`, and return the value returned by the &apos;visitor&period; If this variant is unset, a default constructed `bslmf&colon;&colon;Nil` is passed to the `visitor`&period; Note that this method is selected only if the template parameter type `VISITOR` defines a `typedef` of `ResultType` in its public interface&period; Also note that this method is defined inline to work around a Windows compiler bug with SFINAE functions&period;
| xref:BloombergLP/bdlb/VariantImp/apply-06b.adoc[`apply`] 
| Apply the specified `visitor` to this variant by passing the value this variant currently holds to the `visitor` object&apos;s `operator()`&period; This method does not return a value&period; If this variant is unset, a default constructed `bslmf&colon;&colon;Nil` is passed to the `visitor`&period; Note that this method is selected only if the template parameter type `VISITOR` does not define a `typedef` of `ResultType` in its public interface&period; Also note that this method is defined inline to work around a Windows compiler bug with SFINAE functions&period;
| xref:BloombergLP/bdlb/VariantImp/apply-02f.adoc[`apply`] 
| Apply the specified `visitor` to this modifiable variant by passing the value (of template parameter `TYPE`) this variant currently holds to the `visitor` object&apos;s `operator()`, and return the value (of template parameter `RET&lowbar;TYPE`) returned by the `visitor`&period; If this variant is unset, a default constructed `bslmf&colon;&colon;Nil` is passed to the `visitor`&period;
| xref:BloombergLP/bdlb/VariantImp/apply-0f6.adoc[`apply`] 
| Apply the specified `visitor` to this variant by passing the value this variant currently holds to the `visitor` object&apos;s `operator()`, and return the value (of template parameter `RET&lowbar;TYPE`) returned by the `visitor`&period; If this variant is unset, a default constructed `bslmf&colon;&colon;Nil` is passed to the `visitor`&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 the specified `visitor` to this variant by passing the value this variant currently holds to the `visitor` object&apos;s `operator()`, and return the value (of template parameter `RET&lowbar;TYPE`) returned by the `visitor`&period; If this variant is unset, a default constructed `bslmf&colon;&colon;Nil` is passed to the `visitor`&period;
| xref:BloombergLP/bdlb/VariantImp/apply-08.adoc[`apply`] 
| Apply the specified `visitor` to this modifiable variant by passing the value (of template parameter `TYPE`) this variant currently holds to the `visitor` object&apos;s `operator()`, and return the value returned by the `visitor`&period; If this variant is unset, the specified `defaultValue` of template parameter `TYPE` is passed to the `visitor`&period; `TYPE` must be the same as one of the types that this variant can hold&period; The behavior is undefined unless this variant is unset or holds a value of template parameter `TYPE`&period; Note that this method is selected only if the template parameter type `VISITOR` defines a `typedef` of `ResultType` in its public interface&period; Also note that this method is defined inline to work around a Windows compiler bug with SFINAE functions&period;
| xref:BloombergLP/bdlb/VariantImp/apply-06a.adoc[`apply`] 
| Apply the specified `visitor` to this modifiable variant by passing the value (of template parameter `TYPE`) this variant currently holds to the `visitor` object&apos;s `operator()`&period; This method does not return a value&period; If this variant is unset, the specified `defaultValue` of template parameter `TYPE` is passed to the `visitor`&period; `TYPE` must be the same as one of the types that this variant can hold&period; The behavior is undefined unless this variant is unset or holds a value of template parameter `TYPE`&period; Note that this method is selected only if the template parameter type `VISITOR` does not define a `typedef` of `ResultType` in its public interface&period; Also note that this method is defined inline to work around a Windows compiler bug with SFINAE functions&period;
| xref:BloombergLP/bdlb/VariantImp/apply-0e2.adoc[`apply`] 
| Apply the specified `visitor` to this variant by passing the value (of template parameter `TYPE`) this variant currently holds to the `visitor` object&apos;s `operator()`, and return the value returned by the `visitor`&period; If this variant is unset, the specified `defaultValue` of template parameter `TYPE` is passed to the `visitor`&period; `TYPE` must be the same as one of the types that this variant can hold&period; The behavior is undefined unless this variant is unset or holds a value of template parameter `TYPE`&period; Note that this method is selected only if the template parameter type `VISITOR` defines a `typedef` of `ResultType` in its public interface&period; Also note that this method is defined inline to work around a Windows compiler bug with SFINAE functions&period;
| xref:BloombergLP/bdlb/VariantImp/apply-01.adoc[`apply`] 
| Apply the specified `visitor` to this variant by passing the value (of template parameter `TYPE`) this variant currently holds to the `visitor` object&apos;s `operator()`&period; This method does not return a value&period; If this variant is unset, the specified `defaultValue` of template parameter `TYPE` is passed to the `visitor`&period; `TYPE` must be the same as one of the types that this variant can hold&period; The behavior is undefined unless this variant is unset or holds a value of template parameter `TYPE`&period; Note that this method is selected only if the template parameter type `VISITOR` does not define a `typedef` of `ResultType` in its public interface&period; Also note that this method is defined inline to work around a Windows compiler bug with SFINAE functions&period;
| xref:BloombergLP/bdlb/VariantImp/apply-021.adoc[`apply`] 
| Apply the specified `visitor` to this modifiable variant by passing the value (of template parameter `TYPE`) this variant currently holds to the `visitor` object&apos;s `operator()`, and return the value returned by the `visitor`&period; If this variant is unset, the specified `defaultValue` of template parameter `TYPE` is passed to the `visitor`&period; `TYPE` must be the same as one of the types that this variant can hold&period; The behavior is undefined unless this variant is unset or holds a value of template parameter `TYPE`&period; Note that this method is selected only if the template parameter type `VISITOR` defines a `typedef` of `ResultType` in its public interface&period; Also note that this method is defined inline to work around a Windows compiler bug with SFINAE functions&period;
| xref:BloombergLP/bdlb/VariantImp/apply-0df.adoc[`apply`] 
| Apply the specified `visitor` to this modifiable variant by passing the value (of template parameter `TYPE`) this variant currently holds to the `visitor` object&apos;s `operator()`&period; This method does not return a value&period; If this variant is unset, the specified `defaultValue` of template parameter `TYPE` is passed to the `visitor`&period; `TYPE` must be the same as one of the types that this variant can hold&period; The behavior is undefined unless this variant is unset or holds a value of template parameter `TYPE`&period; Note that this method is selected only if the template parameter type `VISITOR` does not define a `typedef` of `ResultType` in its public interface&period; Also note that this method is defined inline to work around a Windows compiler bug with SFINAE functions&period;
| xref:BloombergLP/bdlb/VariantImp/apply-075f.adoc[`apply`] 
| Apply the specified `visitor` to this variant by passing the value (of template parameter `TYPE`) this variant currently holds to the `visitor` object&apos;s `operator()`, and return the value returned by the `visitor`&period; If this variant is unset, the specified `defaultValue` of template parameter `TYPE` is passed to the `visitor`&period; `TYPE` must be the same as one of the types that this variant can hold&period; The behavior is undefined unless this variant is unset or holds a value of template parameter `TYPE`&period; Note that this method is selected only if the template parameter type `VISITOR` defines a `typedef` of `ResultType` in its public interface&period; Also note that this method is defined inline to work around a Windows compiler bug with SFINAE functions&period;
| xref:BloombergLP/bdlb/VariantImp/apply-0d9.adoc[`apply`] 
| Apply the specified `visitor` to this variant by passing the value (of template parameter `TYPE`) this variant currently holds to the `visitor` object&apos;s `operator()`&period; This method does not return a value&period; If this variant is unset, the specified `defaultValue` of template parameter `TYPE` is passed to the `visitor`&period; `TYPE` must be the same as one of the types that this variant can hold&period; The behavior is undefined unless this variant is unset or holds a value of template parameter `TYPE`&period; Note that this method is selected only if the template parameter type `VISITOR` does not define a `typedef` of `ResultType` in its public interface&period; Also note that this method is defined inline to work around a Windows compiler bug with SFINAE functions&period;
| xref:BloombergLP/bdlb/VariantImp/apply-028.adoc[`apply`] 
| Apply the specified `visitor` to this modifiable variant by passing the value (of template parameter `TYPE`) this variant currently holds to the `visitor` object&apos;s `operator()`, and return the value (of template parameter `RET&lowbar;TYPE`) returned by the `visitor`&period; If this variant is unset, the specified `defaultValue` of template parameter `TYPE` is passed to the `visitor`&period; `TYPE` must be the same as one of the types that this variant can hold&period; The behavior is undefined unless this variant is unset or holds a value of template parameter `TYPE`&period;
| xref:BloombergLP/bdlb/VariantImp/apply-0e3.adoc[`apply`] 
| Apply the specified `visitor` to this variant by passing the value (of template parameter `TYPE`) this variant currently holds to the `visitor` object&apos;s `operator()`, and return the value (of template parameter `RET&lowbar;TYPE`) returned by the `visitor`&period; If this variant is unset, the specified `defaultValue` of template parameter `TYPE` is passed to the `visitor`&period; `TYPE` must be the same as one of the types that this variant can hold&period; The behavior is undefined unless this variant is unset or holds a value of template parameter `TYPE`&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 the specified `visitor` to this variant by passing the value (of template parameter `TYPE`) this variant currently holds to the `visitor` object&apos;s `operator()`, and return the value (of template parameter `RET&lowbar;TYPE`) returned by the `visitor`&period; If this variant is unset, the specified `defaultValue` of template parameter `TYPE` is passed to the `visitor`&period; `TYPE` must be the same as one of the types that this variant can hold&period; The behavior is undefined unless this variant is unset or holds a value of template parameter `TYPE`&period;
| xref:BloombergLP/bdlb/VariantImp/applyRaw-026.adoc[`applyRaw`] 
| Apply the specified `visitor` to this modifiable variant by passing the value (of template parameter `TYPE`) this variant currently holds to the `visitor` object&apos;s `operator()`, and return the value returned by the `visitor`&period; The behavior is undefined if this variant is unset&period; Note that this method is selected only if the template parameter type `VISITOR` defines a `typedef` of `ResultType` in its public interface&period; Also note that this method is defined inline to work around a Windows compiler bug with SFINAE functions&period;
| xref:BloombergLP/bdlb/VariantImp/applyRaw-027.adoc[`applyRaw`] 
| Apply the specified `visitor` to this modifiable variant by passing the value (of template parameter `TYPE`) this variant currently holds to the `visitor` object&apos;s `operator()`&period; This method does not return a value&period; The behavior is undefined if this variant is unset&period; Note that this method is selected only if the template parameter type `VISITOR` does not define a `typedef` of `ResultType` in its public interface&period; Also note that this method is defined inline to work around a Windows compiler bug with SFINAE functions&period;
| xref:BloombergLP/bdlb/VariantImp/applyRaw-0b8.adoc[`applyRaw`] 
| Apply the specified `visitor` to this variant by passing the value this variant currently holds to the `visitor` object&apos;s `operator()`, and return the value (of template parameter `RET&lowbar;TYPE`) returned by the `visitor`&period; The behavior is undefined if this variant is unset&period; Note that this method is selected only if the template parameter type `VISITOR` defines a `typedef` of `ResultType` in its public interface&period; Also note that this method is defined inline to work around a Windows compiler bug with SFINAE functions&period;
| xref:BloombergLP/bdlb/VariantImp/applyRaw-086.adoc[`applyRaw`] 
| Apply the specified `visitor` to this variant by passing the value this variant currently holds to the `visitor` object&apos;s `operator()`&period; This method does not return a value&period; The behavior is undefined if this variant is unset&period; Note that this method is selected only if the template parameter type `VISITOR` does not define a `typedef` of `ResultType` in its public interface&period; Also note that this method is defined inline to work around a Windows compiler bug with SFINAE functions&period;
| xref:BloombergLP/bdlb/VariantImp/applyRaw-01.adoc[`applyRaw`] 
| Apply the specified `visitor` to this modifiable variant by passing the value (of template parameter `TYPE`) this variant currently holds to the `visitor` object&apos;s `operator()`, and return the value returned by the `visitor`&period; The behavior is undefined if this variant is unset&period; Note that this method is selected only if the template parameter type `VISITOR` defines a `typedef` of `ResultType` in its public interface&period; Also note that this method is defined inline to work around a Windows compiler bug with SFINAE functions&period;
| xref:BloombergLP/bdlb/VariantImp/applyRaw-0a.adoc[`applyRaw`] 
| Apply the specified `visitor` to this modifiable variant by passing the value (of template parameter `TYPE`) this variant currently holds to the `visitor` object&apos;s `operator()`&period; This method does not return a value&period; The behavior is undefined if this variant is unset&period; Note that this method is selected only if the template parameter type `VISITOR` does not define a `typedef` of `ResultType` in its public interface&period; Also note that this method is defined inline to work around a Windows compiler bug with SFINAE functions&period;
| xref:BloombergLP/bdlb/VariantImp/applyRaw-0c9.adoc[`applyRaw`] 
| Apply the specified `visitor` to this variant by passing the value this variant currently holds to the `visitor` object&apos;s `operator()`, and return the value returned by the `visitor`&period; The behavior is undefined if this variant is unset&period; Note that this method is selected only if the template parameter type `VISITOR` defines a `typedef` of `ResultType` in its public interface&period; Also note that this method is defined inline to work around a Windows compiler bug with SFINAE functions&period;
| xref:BloombergLP/bdlb/VariantImp/applyRaw-088.adoc[`applyRaw`] 
| Apply the specified `visitor` to this variant by passing the value this variant currently holds to the `visitor` object&apos;s `operator()`&period; This method does not return a value&period; The behavior is undefined if this variant is unset&period; Note that this method is selected only if the template parameter type `VISITOR` does not define a `typedef` of `ResultType` in its public interface&period; Also note that this method is defined inline to work around a Windows compiler bug with SFINAE functions&period;
| xref:BloombergLP/bdlb/VariantImp/applyRaw-0c1.adoc[`applyRaw`] 
| Apply the specified `visitor` to this modifiable variant by passing the value this variant currently holds to the `visitor` object&apos;s `operator()`, and return the value (of template parameter `RET&lowbar;TYPE`) returned by the `visitor`&period; The behavior is undefined if this variant is unset&period;
| xref:BloombergLP/bdlb/VariantImp/applyRaw-0bc.adoc[`applyRaw`] 
| Apply the specified `visitor` to this variant by passing the value this variant currently holds to the `visitor` object&apos;s `operator()`, and return the value (of template parameter `RET&lowbar;TYPE`) returned by the `visitor`&period; The behavior is undefined if this variant is unset&period;
| xref:BloombergLP/bdlb/VariantImp/applyRaw-0c8.adoc[`applyRaw`] 
| Same as the preceding overload, but for a `const` visitor&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 to this object the specified `value` of template parameter `TYPE`, and return a reference providing modifiable access to this object&period; The value currently held by this variant (if any) is destroyed if that value&apos;s type is not the same as `TYPE`&period; `TYPE` must be the same as one of the types that this variant can hold&period;
| xref:BloombergLP/bdlb/VariantImp/assign-0b.adoc[`assign`] 
| Assign to this object the specified `value` of template parameter `TYPE`, and return a reference providing modifiable access to this object&period; The contents of `value` are moved to this object with `value` left in a valid but unspecified state&period; The value currently held by this variant (if any) is destroyed if that value&grave;s type is not the same as `TYPE`&period; `TYPE` must be the same as one of the types that this variant can hold&period;
| xref:BloombergLP/bdlb/VariantImp/assignTo.adoc[`assignTo`] 
| Assign to this object the specified `value` of template parameter `SOURCE&lowbar;TYPE` converted to template parameter `TYPE`, and return a reference providing modifiable access to this object&period; The value currently held by this variant (if any) is destroyed if that value&apos;s type is not the same as `TYPE`&period; `TYPE` must be the same as one of the types that this variant can hold and `SOURCE&lowbar;TYPE` must be convertible to `TYPE`&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`] 
| Create an instance of template parameter `TYPE` in this variant object with up to 14 parameters using the allocator currently held by this variant to supply memory, and return a reference providing modifiable access to the created instance&period; This method first destroys the current value held by this variant (even if `TYPE` is the same as the type currently held)&period; `TYPE` must be the same as one of the types that this variant can hold&period; Note the order of the template arguments was chosen so that `TYPE` must always be specified&period;
| xref:BloombergLP/bdlb/VariantImp/is.adoc[`is`] 
| Return `true` if the value held by this variant object is of template parameter `TYPE`, and `false` otherwise&period; `TYPE` must be the same as one of the types that this variant can hold&period; Note that `TYPE` must be specified explicitly, e&period;g&period;, `myValue&period;is&lt;int&gt;()`&period;
| xref:BloombergLP/bdlb/VariantImp/isUnset.adoc[`isUnset`] 
| Return `true` if this variant is currently unset, and `false` otherwise&period; An unset variant does not hold a value or type&period; Note that this method should be preferred over checking the type index of the variant&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` at the (absolute value of) the optionally specified indentation `level`, and return a reference to `stream`&period; If `level` is specified, optionally specify `spacesPerLevel`, the number of spaces per indentation level for this and all of its nested objects&period; If `level` is negative, suppress indentation of the first line&period; If `spacesPerLevel` is negative, format the entire output on one line, suppressing all but the initial indentation (as governed by `level`)&period; If `stream` is not valid on entry, this operation has no effect&period; Nothing is printed if this variant is unset&period; Each type that may be contained by this variant shall be printable with `bdlb&colon;&colon;PrintMethods` (typically meaning that they either declare the `bdlb&colon;&colon;HasPrintMethod` trait or provide the `&lt;&lt;` output streaming operator)&period; See &lcub;`bdlb&lowbar;printmethods`&rcub;&period; The compiler will emit an error if `bdlb&colon;&colon;PrintMethods&colon;&colon;print` cannot be instantiated for each type that may be contained by this variant&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 the value of the specified `other` object&period; This method provides the no&hyphen;throw guarantee if the `TYPE` template parameter has a no&hyphen;throw `swap` and the two variant objects being swapped have the same type&semi; otherwise this method provides the basic guarantee&period;
| xref:BloombergLP/bdlb/VariantImp/the-0e.adoc[`the`] 
| Return a reference providing modifiable access to the value of template parameter `TYPE` held by this variant object&period; `TYPE` must be the same as one of the types that this variant can hold&period; The behavior is undefined unless `is&lt;TYPE&gt;()` returns `true` and `TYPE` is not `void`&period; Note that `TYPE` must be specified explicitly, e&period;g&period;, `myValue&period;the&lt;int&gt;()`&period;
| xref:BloombergLP/bdlb/VariantImp/the-0a.adoc[`the`] 
| Return a reference providing non&hyphen;modifiable access to the value of template parameter `TYPE` held by this variant object&period; `TYPE` must be the same as one of the types that this variant can hold&period; The behavior is undefined unless `is&lt;TYPE&gt;()` returns `true` and `TYPE` is not `void`&period; Note that `TYPE` must be specified explicitly, e&period;g&period;, `myValue&period;the&lt;int&gt;()`&period;
| xref:BloombergLP/bdlb/VariantImp/typeIndex.adoc[`typeIndex`] 
| Return the index in the list of `TYPES` corresponding to the type of the value currently held by this variant object (starting at 1), or 0 if this object is unset&period; Note that instead of switching code on the type index, calling `apply` is the preferred method of manipulating different types stored inside a variant&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 `true` if the specified `lhs` variant object does not have the same value as the specified `rhs` variant object, and `false` otherwise&period; Two variant objects do not have the same value if one is set and the other is unset, or if they are both set but hold objects that differ in type or 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 `true` if the specified `lhs` variant object has the same value as the specified `rhs` variant object, and `false` otherwise&period; Two variant objects have the same value if they are both set and hold objects of the same type and same value, or are both unset&period;
| xref:BloombergLP/bdlb/swap-04.adoc[`swap`]
| Swap the values of the specified `a` and `b` objects&period; This method provides the no&hyphen;throw guarantee if the `TYPE` template parameter has a no&hyphen;throw `swap` and the two variant objects being swapped has the same type&semi; otherwise this method provides the basic guarantee&period;
|===

== Derived Classes

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bdlb/Variant.adoc[`Variant`] 
| 
| xref:BloombergLP/bdlb/Variant10.adoc[`Variant10`] 
| This class is a &quot;specialization&quot; of `Variant` for a fixed number (10) of types&period; Its 10 template arguments _must_ all be specified (none are defaulted to `bslmf&colon;&colon;Nil`)&period; It provides the same functionality as `Variant&lt;A1, A2, &period;&period;&period;, A10&gt;`&period;
| xref:BloombergLP/bdlb/Variant11.adoc[`Variant11`] 
| This class is a &quot;specialization&quot; of `Variant` for a fixed number (11) of types&period; Its 11 template arguments _must_ all be specified (none are defaulted to `bslmf&colon;&colon;Nil`)&period; It provides the same functionality as `Variant&lt;A1, A2, &period;&period;&period;, A11&gt;`&period;
| xref:BloombergLP/bdlb/Variant12.adoc[`Variant12`] 
| This class is a &quot;specialization&quot; of `Variant` for a fixed number (12) of types&period; Its 12 template arguments _must_ all be specified (none are defaulted to `bslmf&colon;&colon;Nil`)&period; It provides the same functionality as `Variant&lt;A1, A2, &period;&period;&period;, A12&gt;`&period;
| xref:BloombergLP/bdlb/Variant13.adoc[`Variant13`] 
| This class is a &quot;specialization&quot; of `Variant` for a fixed number (13) of types&period; Its 13 template arguments _must_ all be specified (none are defaulted to `bslmf&colon;&colon;Nil`)&period; It provides the same functionality as `Variant&lt;A1, A2, &period;&period;&period;, A13&gt;`&period;
| xref:BloombergLP/bdlb/Variant14.adoc[`Variant14`] 
| This class is a &quot;specialization&quot; of `Variant` for a fixed number (14) of types&period; Its 14 template arguments _must_ all be specified (none are defaulted to `bslmf&colon;&colon;Nil`)&period; It provides the same functionality as `Variant&lt;A1, A2, &period;&period;&period;, A14&gt;`&period;
| xref:BloombergLP/bdlb/Variant15.adoc[`Variant15`] 
| This class is a &quot;specialization&quot; of `Variant` for a fixed number (15) of types&period; Its 15 template arguments _must_ all be specified (none are defaulted to `bslmf&colon;&colon;Nil`)&period; It provides the same functionality as `Variant&lt;A1, A2, &period;&period;&period;, A15&gt;`&period;
| xref:BloombergLP/bdlb/Variant16.adoc[`Variant16`] 
| This class is a &quot;specialization&quot; of `Variant` for a fixed number (16) of types&period; Its 16 template arguments _must_ all be specified (none are defaulted to `bslmf&colon;&colon;Nil`)&period; It provides the same functionality as `Variant&lt;A1, A2, &period;&period;&period;, A16&gt;`&period;
| xref:BloombergLP/bdlb/Variant17.adoc[`Variant17`] 
| This class is a &quot;specialization&quot; of `Variant` for a fixed number (17) of types&period; Its 17 template arguments _must_ all be specified (none are defaulted to `bslmf&colon;&colon;Nil`)&period; It provides the same functionality as `Variant&lt;A1, A2, &period;&period;&period;, A17&gt;`&period;
| xref:BloombergLP/bdlb/Variant18.adoc[`Variant18`] 
| This class is a &quot;specialization&quot; of `Variant` for a fixed number (18) of types&period; Its 18 template arguments _must_ all be specified (none are defaulted to `bslmf&colon;&colon;Nil`)&period; It provides the same functionality as `Variant&lt;A1, A2, &period;&period;&period;, A18&gt;`&period;
| xref:BloombergLP/bdlb/Variant19.adoc[`Variant19`] 
| This class is a &quot;specialization&quot; of `Variant` for a fixed number (19) of types&period; Its 19 template arguments _must_ all be specified (none are defaulted to `bslmf&colon;&colon;Nil`)&period; It provides the same functionality as `Variant&lt;A1, A2, &period;&period;&period;, A19&gt;`&period;
| xref:BloombergLP/bdlb/Variant2.adoc[`Variant2`] 
| This class is a &quot;specialization&quot; of `Variant` for a fixed number (2) of types&period; Its 2 template arguments _must_ all be specified (none are defaulted to `bslmf&colon;&colon;Nil`)&period; It provides the same functionality as `Variant&lt;A1, A2&gt;`&period;
| xref:BloombergLP/bdlb/Variant3.adoc[`Variant3`] 
| This class is a &quot;specialization&quot; of `Variant` for a fixed number (3) of types&period; Its 3 template arguments _must_ all be specified (none are defaulted to `bslmf&colon;&colon;Nil`)&period; It provides the same functionality as `Variant&lt;A1, A2, A3&gt;`&period;
| xref:BloombergLP/bdlb/Variant4.adoc[`Variant4`] 
| This class is a &quot;specialization&quot; of `Variant` for a fixed number (4) of types&period; Its 4 template arguments _must_ all be specified (none are defaulted to `bslmf&colon;&colon;Nil`)&period; It provides the same functionality as `Variant&lt;A1, A2, &period;&period;&period;, A4&gt;`&period;
| xref:BloombergLP/bdlb/Variant5.adoc[`Variant5`] 
| This class is a &quot;specialization&quot; of `Variant` for a fixed number (5) of types&period; Its 5 template arguments _must_ all be specified (none are defaulted to `bslmf&colon;&colon;Nil`)&period; It provides the same functionality as `Variant&lt;A1, A2, &period;&period;&period;, A5&gt;`&period;
| xref:BloombergLP/bdlb/Variant6.adoc[`Variant6`] 
| This class is a &quot;specialization&quot; of `Variant` for a fixed number (6) of types&period; Its 6 template arguments _must_ all be specified (none are defaulted to `bslmf&colon;&colon;Nil`)&period; It provides the same functionality as `Variant&lt;A1, A2, &period;&period;&period;, A6&gt;`&period;
| xref:BloombergLP/bdlb/Variant7.adoc[`Variant7`] 
| This class is a &quot;specialization&quot; of `Variant` for a fixed number (7) of types&period; Its 7 template arguments _must_ all be specified (none are defaulted to `bslmf&colon;&colon;Nil`)&period; It provides the same functionality as `Variant&lt;A1, A2, &period;&period;&period;, A7&gt;`&period;
| xref:BloombergLP/bdlb/Variant8.adoc[`Variant8`] 
| This class is a &quot;specialization&quot; of `Variant` for a fixed number (8) of types&period; Its 8 template arguments _must_ all be specified (none are defaulted to `bslmf&colon;&colon;Nil`)&period; It provides the same functionality as `Variant&lt;A1, A2, &period;&period;&period;, A8&gt;`&period;
| xref:BloombergLP/bdlb/Variant9.adoc[`Variant9`] 
| This class is a &quot;specialization&quot; of `Variant` for a fixed number (9) of types&period; Its 9 template arguments _must_ all be specified (none are defaulted to `bslmf&colon;&colon;Nil`)&period; It provides the same functionality as `Variant&lt;A1, A2, &period;&period;&period;, A9&gt;`&period;
|===


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