Assignment operators

Synopses

Declared in <bslstl_optional.h>

Assign to this object the value of the specified rhs object, and return a non‐`const` reference to this object.

Disengage this object if the specified rhs object is disengaged, and assign to this object the value of rhs.value() (of t_ANY_TYPE) converted to t_TYPE otherwise. Return a reference providing modifiable access to this object. Note that this method does not participate in overload resolution unless t_TYPE and t_ANY_TYPE are compatible. This assignment operator can be called in constant expressions only when neither t_TYPE nor t_ANY_TYPE is allocator‐aware.

template<class t_ANY_TYPE>
constexpr
optional<t_TYPE>&
operator=(optional<t_ANY_TYPE> const& rhs);

Reset this object to be disengaged and return a reference providing modifiable access to this object. This assignment operator can be called in constant expressions only when t_TYPE is not allocator‐aware.

constexpr
optional<t_TYPE>&
operator=(bsl::nullopt_t) noexcept;

Assign to this object the value of the specified rhs object, and return a non‐`const` reference to this object. The allocators of this object and rhs both remain unchanged. The contents of rhs are either move‐constructed into or move‐assigned to this object. rhs is left in a valid but unspecified state.

Disengage this object if the specified rhs object is disengaged, and move assign to this object the value of rhs.value() (of t_ANY_TYPE) converted to t_TYPE otherwise. Return a reference providing modifiable access to this object. Note that this method does not participate in overload resolution unless t_TYPE and t_ANY_TYPE are compatible. This assignment operator can be called in constant expressions only when neither t_TYPE nor t_ANY_TYPE is allocator‐aware.

Disengage this object if the specified rhs object is disengaged, and assign to this object the value of rhs.value() (of t_ANY_TYPE) converted to t_TYPE otherwise. Return a reference providing modifiable access to this object. Note that this method does not participate in overload resolution unless t_TYPE and t_ANY_TYPE are compatible. This assignment operator can be called in constant expressions only when t_TYPE is not allocator‐aware.

template<class t_ANY_TYPE = t_TYPE>
constexpr
optional<t_TYPE>&
operator=(std::optional<t_ANY_TYPE> const& rhs);

Assign to this object the value of the specified rhs object converted to t_TYPE, and return a reference providing modifiable access to this object. Note that this method may invoke assignment from rhs, or construction from rhs, depending on whether this object is engaged. This assignment operator does not participate in overload resolution if t_ANY_TYPE is possibly cv‐qualified bsl::optional<t_TYPE>. Also note that an assignment of the form o = {};, where o is of type optional, will always assign to o the empty state, and never call this overload (see implementation notes). This assignment operator can be called in constant expressions only when t_TYPE is not allocator‐aware.

template<class t_ANY_TYPE = t_TYPE>
constexpr
optional<t_TYPE>&
operator=(t_ANY_TYPE&& rhs);

Disengage this object if the specified rhs object is disengaged, and move assign to this object the value of rhs.value() (of t_ANY_TYPE) converted to t_TYPE otherwise. Return a reference providing modifiable access to this object. Note that this method does not participate in overload resolution unless t_TYPE and t_ANY_TYPE are compatible. This assignment operator can be called in constant expressions only when t_TYPE is not allocator‐aware.

template<class t_ANY_TYPE = t_TYPE>
constexpr
optional<t_TYPE>&
operator=(std::optional<t_ANY_TYPE>&& rhs);

Created with MrDocs