Effects:
If *this contains a value, assigns std​::​forward<U>(v) to the contained value; otherwise initializes the contained value as if direct-non-list-initializing object of type T with std​::​forward<U>(v).

initializes the contained value of *this as if
direct-non-list-initializing an object of type T with the expression std​::​move(*rhs),
followed by rhs.val->T​::​~T();
postcondition is that *this contains a value and rhs does not contain a value

rhs does not contain a value

initializes the contained value of rhs as if
direct-non-list-initializing an object of type T with the expression std​::​move(*(*this)),
followed by val->T​::​~T();
postcondition is that *this does not contain a value and rhs contains a value

The class bad_­optional_­access defines the type of objects thrown as exceptions to report the situation where an attempt is made to access the value of an optional object that does not contain a value.

The specialization hash<optional<T>> is enabled ([unord.hash])
if and only if hash<remove_­const_­t<T>> is enabled.

When enabled, for an object o of type optional<T>,
if bool(o) == true, then hash<optional<T>>()(o)
shall evaluate to the same value as hash<remove_­const_­t<T>>()(*o);
otherwise it evaluates to an unspecified value.