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>

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 VariantImp<bslmf::TypeList11<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11>::ListType>

Base Classes

Name

Description

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

Name

Description

Variant11 [constructor]

Constructors

operator=

Assignment operators

apply

apply overloads

applyRaw

applyRaw overloads

assign

assign overloads

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.

bdexStreamIn

DEPRECATED: Do not use.

bdexStreamOut

DEPRECATED: Do not use.

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.

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>().

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.

maxSupportedBdexVersion

DEPRECATED: Do not use.

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.

reset

Destroy the current value held by this variant (if any), and reset this variant to the unset state.

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.

the

the overloads

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.

typeInfo

Return typeid(void).

operator BloombergLP::bslmf::NestedTraitDeclaration<Variant11, HasPrintMethod>

Nested trait declaration for bdlb::HasPrintMethod.

operator BloombergLP::bslmf::NestedTraitDeclaration<Variant11, IsBitwiseCopyable, Traits::k_VARIANT_IS_BITWISE_COPYABLE>

Nested trait declaration for bslmf::IsBitwiseCopyable.

operator BloombergLP::bslmf::NestedTraitDeclaration<Variant11, IsBitwiseMoveable, Traits::k_VARIANT_IS_BITWISE_MOVEABLE>

Nested trait declaration for bslmf::IsBitwiseMoveable.

operator BloombergLP::bslmf::NestedTraitDeclaration<Variant11, UsesBslmaAllocator, Traits::k_VARIANT_USES_BSLMA_ALLOCATOR>

Nested trait declaration for bslma::UsesBslmaAllocator.

operator BloombergLP::bslmf::NestedTraitDeclaration<VariantImp, HasPrintMethod>

Nested trait declaration for bdlb::HasPrintMethod.

operator BloombergLP::bslmf::NestedTraitDeclaration<VariantImp, IsBitwiseCopyable, Traits::k_VARIANT_IS_BITWISE_COPYABLE>

Nested trait declaration for bslmf::IsBitwiseCopyable.

operator BloombergLP::bslmf::NestedTraitDeclaration<VariantImp, IsBitwiseMoveable, Traits::k_VARIANT_IS_BITWISE_MOVEABLE>

Nested trait declaration for bslmf::IsBitwiseMoveable.

operator BloombergLP::bslmf::NestedTraitDeclaration<VariantImp, UsesBslmaAllocator, Traits::k_VARIANT_USES_BSLMA_ALLOCATOR>

Nested trait declaration for bslma::UsesBslmaAllocator.

Non-Member Functions

Name

Description

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.

operator==

Grant the equality comparison operator access to this class's private members.

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.

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.

Created with MrDocs