cpp/utility/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.
 * Overload is deleted when either  or  is . It is trivial if,  and  are all.
 * Overload does not participate in overload resolution when either  or  is . It is trivial if,  and  are all.

@4@ 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 not,  is ,  is , and at least one of the following is true:
 * is not a scalar type;
 * is not.

@5-6@ 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.
 * These overloads do not participate in overload resolution unless the following conditions are met:
 * is not constructible, convertible, or assignable from any expression of type (possibly ), i.e., the following 12 type traits are all :
 * For overload, and  are both.
 * For overload, and  are both.
 * For overload, and  are both.
 * For overload, and  are both.
 * For overload, and  are both.
 * For overload, and  are both.
 * For overload, and  are both.
 * For overload, and  are both.
 * For overload, and  are both.
 * For overload, and  are both.
 * For overload, and  are both.
 * For overload, and  are both.
 * For overload, and  are both.
 * For overload, and  are both.

Exceptions
@2-6@ 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  and  ) 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 following