[#BloombergLP-bdlb-Variant18]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bdlb.adoc[bdlb]::Variant18
:relfileprefix: ../../
:mrdocs:

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;

== Synopsis

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

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    class A1,
    class A2,
    class A3,
    class A4,
    class A5,
    class A6,
    class A7,
    class A8,
    class A9,
    class A10,
    class A11,
    class A12,
    class A13,
    class A14,
    class A15,
    class A16,
    class A17,
    class A18&gt;
class Variant18
    : public xref:BloombergLP/bdlb/VariantImp.adoc[VariantImp&lt;bslmf::TypeList18&lt;A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18&gt;::ListType&gt;]
----

== Base Classes

[cols="1,4"]
|===
| Name| Description
| `xref:BloombergLP/bdlb/VariantImp.adoc[VariantImp&lt;bslmf::TypeList18&lt;A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18&gt;::ListType&gt;]`
| This class provides the implementation of `Variant` (except for the creators) given a list of template parameter `TYPES`&period;
|===

== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bdlb/Variant18/2constructor-0d8.adoc[`Variant18`]         [.small]#[constructor]#
| Constructors
| xref:BloombergLP/bdlb/Variant18/operator_assign-0a9.adoc[`operator&equals;`] 
| Assignment operators
| xref:BloombergLP/bdlb/Variant18/apply.adoc[`apply`] 
| `apply` overloads
| xref:BloombergLP/bdlb/Variant18/applyRaw.adoc[`applyRaw`] 
| `applyRaw` overloads
| xref:BloombergLP/bdlb/Variant18/assign.adoc[`assign`] 
| `assign` overloads
| 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/Variant18/the.adoc[`the`] 
| `the` overloads
| 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/Variant18/2conversion-0b.adoc[`operator BloombergLP::bslmf::NestedTraitDeclaration&lt;Variant18, HasPrintMethod&gt;`] 
| Nested trait declaration for `bdlb&colon;&colon;HasPrintMethod`&period;
| xref:BloombergLP/bdlb/Variant18/2conversion-03.adoc[`operator BloombergLP::bslmf::NestedTraitDeclaration&lt;Variant18, 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/Variant18/2conversion-07.adoc[`operator BloombergLP::bslmf::NestedTraitDeclaration&lt;Variant18, 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/Variant18/2conversion-04.adoc[`operator BloombergLP::bslmf::NestedTraitDeclaration&lt;Variant18, UsesBslmaAllocator, Traits&colon;&colon;k&lowbar;VARIANT&lowbar;USES&lowbar;BSLMA&lowbar;ALLOCATOR&gt;`] 
| Nested trait declaration for `bslma&colon;&colon;UsesBslmaAllocator`&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;
|===


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