[#bsl-variant-2constructor-030] = xref:bsl.adoc[bsl]::xref:bsl/variant.adoc[variant]::variant :relfileprefix: ../../ :mrdocs: Create a `variant` object whose contained value is initialized from `t` using `allocator`. == Synopsis Declared in `<bslstl_variant.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<class t_TYPE> variant( std::allocator_arg_t allocatorArg, xref:bsl/variant/allocator_type.adoc[allocator_type] allocator, t_TYPE&& t); ---- == Description Create a `variant` object whose contained value is direct‐initialized from the specified `t`. The alternative selected is the best match among all alternatives for which the expression `t_ALT_TYPE x[]= {std::forward<t_TYPE>(t)};` is well formed, and this constructor participates in overload resolution only if there is a unique best matching alternative and that alternative is constructible from `t`. If this `variant` is allocator‐aware, the specified `allocator` is used to supply memory. Note that the cv‐qualification of an alternative type does not affect how well the alternative type matches an argument type. == Parameters [cols="1,4"] |=== | Name| Description | *allocatorArg* | tag selecting the allocator‐extended overload | *allocator* | allocator used to supply memory | *t* | value used to initialize the selected alternative |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#