BloombergLP::bslstl::Optional_Base::value_or

Return the contained value, or a converted fallback if disengaged.

Synopsis

Declared in <bslstl_optional.h>

template<class t_ANY_TYPE>
t_TYPE
value_or(t_ANY_TYPE&& value) const &;

Description

Return a copy of the underlying object of a (template parameter) t_TYPE if this object is non-null, and the specified value converted to t_TYPE 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

NameDescription
valuevalue compared with or used to initialize the optional