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

Create a variant from `valueOrAllocator`&period;

== Synopsis

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

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class TYPE&lowbar;OR&lowbar;ALLOCATOR&gt;
explicit
Variant(TYPE&lowbar;OR&lowbar;ALLOCATOR const& valueOrAllocator);
----

== Description

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 &grave;bslma&colon;&colon;Allocator &ast;&grave;)&period;

== Parameters

[cols="1,4"]
|===
| Name| Description
| *valueOrAllocator*
| held value, or allocator if convertible to `bslma&colon;&colon;Allocator &ast;`
|===


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