Concept Subspace :: sus :: cmp :: Eq

template <class T, class U = T>
concept Eq
requires
requires(const std::remove_reference_t<T>& lhs,
                      const std::remove_reference_t<U>& rhs) {
  { lhs == rhs } -> std::same_as<bool>;
  { lhs != rhs } -> std::same_as<bool>;
}

Concept for types that can be compared for equality with the == and != operators. There is no guarantee of a full equivalence relation, and a partial equivalence is possible, which allows for values that compare not-equal to themselves (such as NaN).

Implementations must ensure that operator== and operator!= are consistent with each other:

  • a != b if and only if !(a == b).

The default implementation of operator!= provides this consistency and is almost always sufficient. It should not be overridden without very good reason.

This maps to the PartialEq trait in Rust rather than the Eq trait. Since C++ does not understand equivalent vs partial equivalence, we are unable to differentiate and provide a stronger relationship than partial equivalence.