[#BloombergLP-bslstl-Optional_Base-05-value_or-041] = xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bslstl.adoc[bslstl]::xref:BloombergLP/bslstl/Optional_Base-05.adoc[Optional_Base]::value_or :relfileprefix: ../../../ :mrdocs: Return the contained value, or a converted fallback if disengaged. == Synopsis Declared in `<bslstl_optional.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<class t_ANY_TYPE> t_TYPE value_or( std::allocator_arg_t allocatorArg, xref:BloombergLP/bslstl/Optional_Base-05/allocator_type.adoc[allocator_type] allocator, t_ANY_TYPE&& value) const &; ---- == Description If this object is non‐null, return a copy of the underlying object of a (template parameter) `t_TYPE` created using the provided allocator, and the specified `value` converted to `t_TYPE` using the specified `allocator` otherwise. Note that this method returns _by_ _value_, so may be inefficient in some contexts. == Return Value contained value if engaged, otherwise `value` converted to `t_TYPE` == Parameters [cols="1,4"] |=== | Name| Description | *allocatorArg* | tag selecting the allocator‐extended constructor | *allocator* | allocator used to supply memory | *value* | value compared with or used to initialize the optional |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#