[#bsl-optional-072-operator_assign-08] = xref:bsl.adoc[bsl]::xref:bsl/optional-072.adoc[optional]::operator= :relfileprefix: ../../ :mrdocs: Assign a new value to this optional. == Synopsis Declared in `<bslstl_optional.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<class t_ANY_TYPE> constexpr xref:bsl/optional-072.adoc[optional<t_TYPE>]& operator=(xref:bsl/optional-072.adoc[optional<t_ANY_TYPE>] const& rhs); ---- == Description 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. == Return Value reference providing modifiable access to this object == Parameters [cols="1,4"] |=== | Name| Description | *rhs* | right‐hand operand |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#