title: How is std::optional never "valueless by exception"?
body: <p><code>std::variant</code> can enter a state called &quot;<a href="https://en.cppreference.com/w/cpp/utility/variant/valueless_by_exception" rel="noreferrer">valueless by exception</a>&quot;.</p>
  <p>As I understand, the common cause of this is if a move assignment throws an exception.  The variant's old value isn't guaranteed to be present anymore, and neither is the intended new value.</p>
  <p><code>std::optional</code>, however, doesn't have such a state.  cppreference makes the bold claim:</p>
  <blockquote>
  <p>If an exception is thrown, the initialization state of *this ... is unchanged, i.e. if the object contained a value, it still contains a value, and the other way round.</p>
  </blockquote>
  <p>How is <code>std::optional</code> able to avoid becoming &quot;valueless by exception&quot;, while <code>std::variant</code> is not?</p>