[#BloombergLP-bdlb-Variant10-2constructor-07] = xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bdlb.adoc[bdlb]::xref:BloombergLP/bdlb/Variant10.adoc[Variant10]::Variant10 :relfileprefix: ../../../ :mrdocs: Constructors == Synopses Declared in `<bdlb_variant.h>` Create a variant object in the unset state that uses the currently installed default allocator to supply memory. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:BloombergLP/bdlb/Variant10/2constructor-01.adoc[Variant10](); ---- [.small]#xref:BloombergLP/bdlb/Variant10/2constructor-01.adoc[_» more..._]# Create a variant object having the type and value of the specified `original` object by moving the contents of `original` to the newly‐created object. The allocator associated with `original` (if any) is propagated for use in the newly‐created object. `original` is left in a valid but unspecified state. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:BloombergLP/bdlb/Variant10/2constructor-025.adoc[Variant10](xref:BloombergLP/bslmf/MovableRef.adoc[bslmf::MovableRef<Variant10>] original); ---- [.small]#xref:BloombergLP/bdlb/Variant10/2constructor-025.adoc[_» more..._]# 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. If `valueOrAllocator` is not a `bslma::Allocator *`, then the variant will hold the value and type of `valueOrAllocator`, and use the currently installed default allocator to supply memory. Otherwise, the variant will be unset and use `valueOrAllocator` to supply memory. `TYPE_OR_ALLOCATOR` must be the same as one of the types that this variant can hold or be convertible to `bslma::Allocator *`. Note that this parameterized constructor is defined instead of two constructors (one taking a `bslma::Allocator *` and the other not) because template parameter arguments are always a better match than derived‐to‐base conversion (a concrete allocator pointer converted to `bslma::Allocator *`). [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<class TYPE_OR_ALLOCATOR> explicit xref:BloombergLP/bdlb/Variant10/2constructor-08b.adoc[Variant10](TYPE_OR_ALLOCATOR const& valueOrAllocator); ---- [.small]#xref:BloombergLP/bdlb/Variant10/2constructor-08b.adoc[_» more..._]# Create a variant object having the type and value of the specified `original` object that uses the specified `basicAllocator` to supply memory. If `basicAllocator` is 0, the currently installed default allocator is used. The contents of `original` are moved to the newly‐created object with `original` left in a valid but unspecified state. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:BloombergLP/bdlb/Variant10/2constructor-03.adoc[Variant10]( xref:BloombergLP/bslmf/MovableRef.adoc[bslmf::MovableRef<Variant10>] original, xref:BloombergLP/bslma/Allocator.adoc[bslma::Allocator]* basicAllocator); ---- [.small]#xref:BloombergLP/bdlb/Variant10/2constructor-03.adoc[_» more..._]# Create a variant object having the type and value of the specified `original` variant. Optionally specify a `basicAllocator` used to supply memory. If `basicAllocator` is 0, the currently installed default allocator is used. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:BloombergLP/bdlb/Variant10/2constructor-0c.adoc[Variant10]( xref:BloombergLP/bdlb/Variant10.adoc[Variant10] const& original, xref:BloombergLP/bslma/Allocator.adoc[bslma::Allocator]* basicAllocator = 0); ---- [.small]#xref:BloombergLP/bdlb/Variant10/2constructor-0c.adoc[_» more..._]# Create a variant object having the specified `value` of template parameter `TYPE` and that uses the specified `basicAllocator` to supply memory. If `basicAllocator` is 0, the currently installed default allocator is used. `TYPE` must be the same as one of the types that this variant can hold. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<class TYPE> xref:BloombergLP/bdlb/Variant10/2constructor-02d.adoc[Variant10]( TYPE const& value, xref:BloombergLP/bslma/Allocator.adoc[bslma::Allocator]* basicAllocator); ---- [.small]#xref:BloombergLP/bdlb/Variant10/2constructor-02d.adoc[_» more..._]# Create a variant object having the specified `value` of template parameter `TYPE` by moving the contents of `value` to the newly‐created object. Use the currently installed default allocator to supply memory. `value` is left in a valid but unspecified state. `TYPE` must be the same as one of the types that this variant can hold. Note that in C++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). [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<class TYPE> explicit xref:BloombergLP/bdlb/Variant10/2constructor-0b.adoc[Variant10]( TYPE&& value, void* = 0) requires !bsl::is_same< SelfType, typename bsl::remove_const< typename bsl::remove_reference<TYPE>::type>::type>::value && !bsl::is_convertible<TYPE, bslma::Allocator *>::value; ---- [.small]#xref:BloombergLP/bdlb/Variant10/2constructor-0b.adoc[_» more..._]# Create a variant object having the specified `value` of template parameter `TYPE` that uses the specified `basicAllocator` to supply memory. If `basicAllocator` is 0, the currently installed default allocator is used. The contents of `value` are moved to the newly‐created object with `value` left in a valid but unspecified state. `TYPE` must be the same as one of the types that this variant can hold. Note that in C++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). [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<class TYPE> xref:BloombergLP/bdlb/Variant10/2constructor-086.adoc[Variant10]( TYPE&& value, xref:BloombergLP/bslma/Allocator.adoc[bslma::Allocator]* basicAllocator) requires !bsl::is_same< SelfType, typename bsl::remove_const< typename bsl::remove_reference<TYPE>::type>::type>::value; ---- [.small]#xref:BloombergLP/bdlb/Variant10/2constructor-086.adoc[_» more..._]# [.small]#Created with https://www.mrdocs.com[MrDocs]#