https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96269

--- Comment #9 from Ville Voutilainen <ville.voutilainen at gmail dot com> ---
Ha, well spotted. In general, in a spaceship world, you do want to provide
comparisons symmetrically and const-correctly, and that also works in the
pre-spaceship world, thus:

#include <optional>

struct X {
  template <typename T>
  bool operator==(const T&) const {
    return false;
  }
  template <typename T> friend bool operator==(const T&, const X&) {return
false;}
};

bool foo() {
  std::optional<X> x;
#ifndef FLIP
  return x == std::nullopt;
#else
  return std::nullopt == x;
#endif
}

Reply via email to