[#bsl-optional-072-operator_assign-0d]
= xref:bsl.adoc[bsl]::xref:bsl/optional-072.adoc[optional]::operator&equals;
:relfileprefix: ../../
:mrdocs:

Assign a new value to this optional&period;

== Synopsis

Declared in `&lt;bslstl&lowbar;optional&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class t&lowbar;ANY&lowbar;TYPE = t&lowbar;TYPE&gt;
constexpr
xref:bsl/optional-072.adoc[optional&lt;t&lowbar;TYPE&gt;]&
operator&equals;(t&lowbar;ANY&lowbar;TYPE&& rhs);
----

== Description

Assign to this object the value of the specified `rhs` object converted to `t&lowbar;TYPE`, and return a reference providing modifiable access to this object&period; Note that this method may invoke assignment from `rhs`, or construction from `rhs`, depending on whether this object is engaged&period; This assignment operator does not participate in overload resolution if `t&lowbar;ANY&lowbar;TYPE` is possibly cv&hyphen;qualified `bsl&colon;&colon;optional&lt;t&lowbar;TYPE&gt;`&period; Also note that an assignment of the form `o &equals; &lcub;&rcub;&semi;`, where `o` is of type `optional`, will always assign to `o` the empty state, and never call this overload (see implementation notes)&period; This assignment operator can be called in constant expressions only when `t&lowbar;TYPE` is not allocator&hyphen;aware&period;

== Return Value

reference providing modifiable access to this object

== Parameters

[cols="1,4"]
|===
| Name| Description
| *rhs*
| right&hyphen;hand operand
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
