17 Language support library [language.support]

17.11 Comparisons [cmp]

17.11.2 Comparison category types [cmp.categories]

17.11.2.3 Class strong_­equality [cmp.strongeq]

The strong_­equality type is typically used as the result type of a three-way comparison operator that (a) admits only equality and inequality comparisons, and (b) does imply substitutability.
namespace std {
  class strong_equality {
    int value;  // exposition only

    // exposition-only constructor
    constexpr explicit strong_equality(eq v) noexcept : value(int(v)) {}    // exposition only

  public:
    // valid values
    static const strong_equality equal;
    static const strong_equality nonequal;
    static const strong_equality equivalent;
    static const strong_equality nonequivalent;

    // conversion
    constexpr operator weak_equality() const noexcept;

    // comparisons
    friend constexpr bool operator==(strong_equality v, unspecified) noexcept;
    friend constexpr bool operator==(strong_equality v, strong_equality w) noexcept = default;
    friend constexpr strong_equality operator<=>(strong_equality v, unspecified) noexcept;
    friend constexpr strong_equality operator<=>(unspecified, strong_equality v) noexcept;
  };

  // valid values' definitions
  inline constexpr strong_equality strong_equality::equal(eq::equal);
  inline constexpr strong_equality strong_equality::nonequal(eq::nonequal);
  inline constexpr strong_equality strong_equality::equivalent(eq::equivalent);
  inline constexpr strong_equality strong_equality::nonequivalent(eq::nonequivalent);
}
constexpr operator weak_equality() const noexcept;
Returns: value == 0 ? weak_­equality​::​equivalent : weak_­equality​::​nonequivalent.
constexpr bool operator==(strong_equality v, unspecified) noexcept;
Returns: v.value == 0.
constexpr strong_equality operator<=>(strong_equality v, unspecified) noexcept; constexpr strong_equality operator<=>(unspecified, strong_equality v) noexcept;
Returns: v.