[#BloombergLP-bdlb-Variant11] = xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bdlb.adoc[bdlb]::Variant11 :relfileprefix: ../../ :mrdocs: This class is a "specialization" of `Variant` for a fixed number (11) of types. Its 11 template arguments _must_ all be specified (none are defaulted to `bslmf::Nil`). It provides the same functionality as `Variant<A1, A2, ..., A11>`. == Synopsis Declared in `<bdlb_variant.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template< class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10, class A11> class Variant11 : public xref:BloombergLP/bdlb/VariantImp.adoc[VariantImp<bslmf::TypeList11<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11>::ListType>] ---- == Base Classes [cols="1,4"] |=== | Name| Description | `xref:BloombergLP/bdlb/VariantImp.adoc[VariantImp<bslmf::TypeList11<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11>::ListType>]` | This class provides the implementation of `Variant` (except for the creators) given a list of template parameter `TYPES`. |=== == Member Functions [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bdlb/Variant11/2constructor-01d.adoc[`Variant11`] [.small]#[constructor]# | Constructors | xref:BloombergLP/bdlb/Variant11/operator_assign-02.adoc[`operator=`] | Assignment operators | xref:BloombergLP/bdlb/Variant11/apply.adoc[`apply`] | `apply` overloads | xref:BloombergLP/bdlb/Variant11/applyRaw.adoc[`applyRaw`] | `applyRaw` overloads | xref:BloombergLP/bdlb/Variant11/assign.adoc[`assign`] | `assign` overloads | xref:BloombergLP/bdlb/VariantImp/assignTo.adoc[`assignTo`] | Assign to this object the specified `value` of template parameter `SOURCE_TYPE` converted to template parameter `TYPE`, and return a reference providing modifiable access to this object. The value currently held by this variant (if any) is destroyed if that value's type is not the same as `TYPE`. `TYPE` must be the same as one of the types that this variant can hold and `SOURCE_TYPE` must be convertible to `TYPE`. | 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`] | 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. This method first destroys the current value held by this variant (even if `TYPE` is the same as the type currently held). `TYPE` must be the same as one of the types that this variant can hold. Note the order of the template arguments was chosen so that `TYPE` must always be specified. | 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. `TYPE` must be the same as one of the types that this variant can hold. Note that `TYPE` must be specified explicitly, e.g., `myValue.is<int>()`. | xref:BloombergLP/bdlb/VariantImp/isUnset.adoc[`isUnset`] | Return `true` if this variant is currently unset, and `false` otherwise. An unset variant does not hold a value or type. Note that this method should be preferred over checking the type index of the variant. | 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` at the (absolute value of) the optionally specified indentation `level`, and return a reference to `stream`. If `level` is specified, optionally specify `spacesPerLevel`, the number of spaces per indentation level for this and all of its nested objects. If `level` is negative, suppress indentation of the first line. If `spacesPerLevel` is negative, format the entire output on one line, suppressing all but the initial indentation (as governed by `level`). If `stream` is not valid on entry, this operation has no effect. Nothing is printed if this variant is unset. Each type that may be contained by this variant shall be printable with `bdlb::PrintMethods` (typically meaning that they either declare the `bdlb::HasPrintMethod` trait or provide the `<<` output streaming operator). See {`bdlb_printmethods`}. The compiler will emit an error if `bdlb::PrintMethods::print` cannot be instantiated for each type that may be contained by this variant. | 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 the value of the specified `other` object. This method provides the no‐throw guarantee if the `TYPE` template parameter has a no‐throw `swap` and the two variant objects being swapped have the same type; otherwise this method provides the basic guarantee. | xref:BloombergLP/bdlb/Variant11/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. Note that instead of switching code on the type index, calling `apply` is the preferred method of manipulating different types stored inside a variant. | xref:BloombergLP/bdlb/VariantImp/typeInfo.adoc[`typeInfo`] | Return `typeid(void)`. | xref:BloombergLP/bdlb/Variant11/2conversion-02.adoc[`operator BloombergLP::bslmf::NestedTraitDeclaration<Variant11, HasPrintMethod>`] | Nested trait declaration for `bdlb::HasPrintMethod`. | xref:BloombergLP/bdlb/Variant11/2conversion-0a42c.adoc[`operator BloombergLP::bslmf::NestedTraitDeclaration<Variant11, IsBitwiseCopyable, Traits::k_VARIANT_IS_BITWISE_COPYABLE>`] | Nested trait declaration for `bslmf::IsBitwiseCopyable`. | xref:BloombergLP/bdlb/Variant11/2conversion-04.adoc[`operator BloombergLP::bslmf::NestedTraitDeclaration<Variant11, IsBitwiseMoveable, Traits::k_VARIANT_IS_BITWISE_MOVEABLE>`] | Nested trait declaration for `bslmf::IsBitwiseMoveable`. | xref:BloombergLP/bdlb/Variant11/2conversion-0a42a.adoc[`operator BloombergLP::bslmf::NestedTraitDeclaration<Variant11, UsesBslmaAllocator, Traits::k_VARIANT_USES_BSLMA_ALLOCATOR>`] | Nested trait declaration for `bslma::UsesBslmaAllocator`. | 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 `true` if the specified `lhs` variant object does not have the same value as the specified `rhs` variant object, and `false` otherwise. 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. | 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 `true` if the specified `lhs` variant object has the same value as the specified `rhs` variant object, and `false` otherwise. 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. | xref:BloombergLP/bdlb/swap-04.adoc[`swap`] | Swap the values of the specified `a` and `b` objects. This method provides the no‐throw guarantee if the `TYPE` template parameter has a no‐throw `swap` and the two variant objects being swapped has the same type; otherwise this method provides the basic guarantee. |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#