[#BloombergLP-bdlb-Variant8-2constructor-0e]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bdlb.adoc[bdlb]::xref:BloombergLP/bdlb/Variant8.adoc[Variant8]::Variant8
:relfileprefix: ../../../
:mrdocs:

Constructors

== Synopses

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

Create a variant object in the unset state that uses the currently installed default allocator to supply memory&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
xref:BloombergLP/bdlb/Variant8/2constructor-04.adoc[Variant8]();
----

[.small]#xref:BloombergLP/bdlb/Variant8/2constructor-04.adoc[_» more&period;&period;&period;_]#

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;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
xref:BloombergLP/bdlb/Variant8/2constructor-013.adoc[Variant8](xref:BloombergLP/bslmf/MovableRef.adoc[bslmf::MovableRef&lt;Variant8&gt;] original);
----

[.small]#xref:BloombergLP/bdlb/Variant8/2constructor-013.adoc[_» more&period;&period;&period;_]#

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;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class TYPE&lowbar;OR&lowbar;ALLOCATOR&gt;
explicit
xref:BloombergLP/bdlb/Variant8/2constructor-0c7.adoc[Variant8](TYPE&lowbar;OR&lowbar;ALLOCATOR const& valueOrAllocator);
----

[.small]#xref:BloombergLP/bdlb/Variant8/2constructor-0c7.adoc[_» more&period;&period;&period;_]#

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;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
xref:BloombergLP/bdlb/Variant8/2constructor-08.adoc[Variant8](
    xref:BloombergLP/bslmf/MovableRef.adoc[bslmf::MovableRef&lt;Variant8&gt;] original,
    xref:BloombergLP/bslma/Allocator.adoc[bslma::Allocator]* basicAllocator);
----

[.small]#xref:BloombergLP/bdlb/Variant8/2constructor-08.adoc[_» more&period;&period;&period;_]#

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;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
xref:BloombergLP/bdlb/Variant8/2constructor-06.adoc[Variant8](
    xref:BloombergLP/bdlb/Variant8.adoc[Variant8] const& original,
    xref:BloombergLP/bslma/Allocator.adoc[bslma::Allocator]* basicAllocator = 0);
----

[.small]#xref:BloombergLP/bdlb/Variant8/2constructor-06.adoc[_» more&period;&period;&period;_]#

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;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class TYPE&gt;
xref:BloombergLP/bdlb/Variant8/2constructor-0ce.adoc[Variant8](
    TYPE const& value,
    xref:BloombergLP/bslma/Allocator.adoc[bslma::Allocator]* basicAllocator);
----

[.small]#xref:BloombergLP/bdlb/Variant8/2constructor-0ce.adoc[_» more&period;&period;&period;_]#

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;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class TYPE&gt;
explicit
xref:BloombergLP/bdlb/Variant8/2constructor-01c.adoc[Variant8](
    TYPE&& value,
    void* = 0)
requires !bsl&colon;&colon;is&lowbar;same&lt;
                      SelfType,
                      typename bsl&colon;&colon;remove&lowbar;const&lt;
                      typename bsl&colon;&colon;remove&lowbar;reference&lt;TYPE&gt;&colon;&colon;type&gt;&colon;&colon;type&gt;&colon;&colon;value
                 &amp;&amp;
                 !bsl&colon;&colon;is&lowbar;convertible&lt;TYPE, bslma&colon;&colon;Allocator &ast;&gt;&colon;&colon;value;
----

[.small]#xref:BloombergLP/bdlb/Variant8/2constructor-01c.adoc[_» more&period;&period;&period;_]#

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;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class TYPE&gt;
xref:BloombergLP/bdlb/Variant8/2constructor-0a.adoc[Variant8](
    TYPE&& value,
    xref:BloombergLP/bslma/Allocator.adoc[bslma::Allocator]* basicAllocator)
requires !bsl&colon;&colon;is&lowbar;same&lt;
                     SelfType,
                     typename bsl&colon;&colon;remove&lowbar;const&lt;
                     typename bsl&colon;&colon;remove&lowbar;reference&lt;TYPE&gt;&colon;&colon;type&gt;&colon;&colon;type&gt;&colon;&colon;value;
----

[.small]#xref:BloombergLP/bdlb/Variant8/2constructor-0a.adoc[_» more&period;&period;&period;_]#


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