[concept.equalitycomparable] (original) (raw)
18 Concepts library [concepts]
18.5 Comparison concepts [concepts.compare]
18.5.3 Concept equality_comparable [concept.equalitycomparable]
Given types T and U, let t and u be lvalues of typesconst remove_reference_t<T> andconst remove_reference_t<U> respectively.
T and U model_weakly-equality-comparable-with_<T, U> only if
- t == u, u == t, t != u, and u != t have the same domain.
- bool(u == t) == bool(t == u).
- bool(t != u) == !bool(t == u).
- bool(u != t) == bool(t != u).
template<class T> concept [equality_comparable](#concept:equality%5Fcomparable "18.5.3 Concept equality_comparable [concept.equalitycomparable]") = [_weakly-equality-comparable-with_](#concept:weakly-equality-comparable-with "18.5.3 Concept equality_comparable [concept.equalitycomparable]")<T, T>;
Let a and b be objects of type T.
T models equality_comparable only ifbool(a == b) is true when a is equal tob ([concepts.equality]), and false otherwise.
[Note 1:
The requirement that the expression a == b is equality-preserving implies that == is transitive and symmetric.
— _end note_]
template<class T, class U> concept [equality_comparable_with](#concept:equality%5Fcomparable%5Fwith "18.5.3 Concept equality_comparable [concept.equalitycomparable]") = equality_comparable<T> && equality_comparable<U> && common_reference_with<const remove_reference_t<T>&, const remove_reference_t<U>&> && equality_comparable< common_reference_t< const remove_reference_t<T>&,const remove_reference_t<U>&>> && [_weakly-equality-comparable-with_](#concept:weakly-equality-comparable-with "18.5.3 Concept equality_comparable [concept.equalitycomparable]")<T, U>;
Given types T and U, let t be an lvalue of type const remove_reference_t<T>,u be an lvalue of type const remove_reference_t<U>, and C be:common_reference_t<const remove_reference_t<T>&, const remove_reference_t<U>&> T and U modelequality_comparable_with<T, U> only ifbool(t == u) == bool(C(t) == C(u)).