title: In which cases does std::optional operator == cause undefined behavior?
body: <p><a href="https://en.cppreference.com/w/cpp/utility/optional/operator_cmp" rel="nofollow noreferrer">Cppreference</a> has the following description of mixed (optional and some other non-optional type) comparison operators for <code>std::optional</code>:</p>
  <blockquote>
  <p>Compares opt with a value. The values are compared (using the
  corresponding operator of T) only if opt contains a value. Otherwise,
  opt is considered less than value. If the corresponding two-way
  comparison expression between *opt and value is not well-formed, or if
  its result is not convertible to bool, the behavior is undefined.</p>
  </blockquote>
  <p>What confuses me here is:</p>
  <ul>
  <li><p>What would be examples of these not well-formed comparisons?</p>
  </li>
  <li><p>Why don't compilers/STL just reject the invalid comparisons instead of giving us UB?</p>
  </li>
  </ul>