cpp/experimental/optional/operator=

Replaces contents of with the contents of

@1@ If contains a value before the call, the contained value is destroyed by calling its destructor as if by. does not contain a value after this call.

@2-3@ Assigns the state of.
 * If both and  do not contain a value, the function has no effect.
 * If contains a value, but  does not, then the contained value is destroyed by calling its destructor.  does not contain a value after the call.
 * If contains a value, then depending on whether  contains a value, the contained value is either direct-initialized or assigned from   or  . Note that a moved-from optional still contains a value.

@4@ Decay-only perfect-forwarded assignment: depending on whether contains a value before the call, the contained value is either direct-initialized from  or assigned from. The function does not participate in overload resolution unless is.

Exceptions
@2-4@ Throws any exception thrown by the constructor or assignment operator of. If an exception is thrown, the initialization state of (and of  in case of (2) ) is unchanged, i.e. if the object contained a value, it still contains a value, and the other way round. The contents of and the contained values of  and  depend on the exception safety guarantees of the operation from which the exception originates (copy-constructor, move-assignment, etc.). has the following declaration: