The library provides basic function object classes for all of the comparison operators in the language ( ISO/IEC 14882:2014 §[expr.rel], ISO/IEC 14882:2014 §[expr.eq]).
In this section, BUILTIN_PTR_CMP(T, op, U) for types T and U and where op is an equality ( ISO/IEC 14882:2014 §[expr.eq]) or relational operator ( ISO/IEC 14882:2014 §[expr.rel]) is a boolean constant expression. BUILTIN_PTR_CMP(T, op, U) is true if and only if op in the expression declval<T>() op declval<U>() resolves to a built-in operator comparing pointers.
There is an implementation-defined strict total ordering over all pointer values of a given type. This total ordering is consistent with the partial order imposed by the builtin operators <, >, <=, and >=.
template <class T = void>
requires EqualityComparable<T> || Same<T, void> || BUILTIN_PTR_CMP(const T&, ==, const T&)
struct equal_to {
constexpr bool operator()(const T& x, const T& y) const;
};
operator() has effects equivalent to: return equal_to<>{}(x, y);
template <class T = void>
requires EqualityComparable<T> || Same<T, void> || BUILTIN_PTR_CMP(const T&, ==, const T&)
struct not_equal_to {
constexpr bool operator()(const T& x, const T& y) const;
};
operator() has effects equivalent to: return !equal_to<>{}(x, y);
template <class T = void>
requires StrictTotallyOrdered<T> || Same<T, void> || BUILTIN_PTR_CMP(const T&, <, const T&)
struct greater {
constexpr bool operator()(const T& x, const T& y) const;
};
operator() has effects equivalent to: return less<>{}(y, x);
template <class T = void>
requires StrictTotallyOrdered<T> || Same<T, void> || BUILTIN_PTR_CMP(const T&, <, const T&)
struct less {
constexpr bool operator()(const T& x, const T& y) const;
};
operator() has effects equivalent to: return less<>{}(x, y);
template <class T = void>
requires StrictTotallyOrdered<T> || Same<T, void> || BUILTIN_PTR_CMP(const T&, <, const T&)
struct greater_equal {
constexpr bool operator()(const T& x, const T& y) const;
};
operator() has effects equivalent to: return !less<>{}(x, y);
template <class T = void>
requires StrictTotallyOrdered<T> || Same<T, void> || BUILTIN_PTR_CMP(const T&, <, const T&)
struct less_equal {
constexpr bool operator()(const T& x, const T& y) const;
};
operator() has effects equivalent to: return !less<>{}(y, x);
template <> struct equal_to<void> {
template <class T, class U>
requires EqualityComparableWith<T, U> || BUILTIN_PTR_CMP(T, ==, U)
constexpr bool operator()(T&& t, U&& u) const;
typedef unspecified is_transparent;
};
Requires: If the expression std::forward<T>(t) == std::forward<U>(u) results in a call to a built-in operator == comparing pointers of type P, the conversion sequences from both T and U to P shall be equality-preserving ([concepts.lib.general.equality]).
Effects:
If the expression std::forward<T>(t) == std::forward<U>(u) results in a call to a built-in operator == comparing pointers of type P: returns false if either (the converted value of) t precedes u or u precedes t in the implementation-defined strict total order over pointers of type P and otherwise true.
Otherwise, equivalent to: return std::forward<T>(t) == std::forward<U>(u);
template <> struct not_equal_to<void> {
template <class T, class U>
requires EqualityComparableWith<T, U> || BUILTIN_PTR_CMP(T, ==, U)
constexpr bool operator()(T&& t, U&& u) const;
typedef unspecified is_transparent;
};
operator() has effects equivalent to:
return !equal_to<>{}(std::forward<T>(t), std::forward<U>(u));
template <> struct greater<void> {
template <class T, class U>
requires StrictTotallyOrderedWith<T, U> || BUILTIN_PTR_CMP(U, <, T)
constexpr bool operator()(T&& t, U&& u) const;
typedef unspecified is_transparent;
};
operator() has effects equivalent to:
return less<>{}(std::forward<U>(u), std::forward<T>(t));
template <> struct less<void> {
template <class T, class U>
requires StrictTotallyOrderedWith<T, U> || BUILTIN_PTR_CMP(T, <, U)
constexpr bool operator()(T&& t, U&& u) const;
typedef unspecified is_transparent;
};
Requires: If the expression std::forward<T>(t) < std::forward<U>(u) results in a call to a built-in operator < comparing pointers of type P, the conversion sequences from both T and U to P shall be equality-preserving ([concepts.lib.general.equality]). For any expressions ET and EU such that decltype((ET)) is T and decltype((EU)) is U, exactly one of less<>{}(ET, EU), less<>{}(EU, ET) or equal_to<>{}(ET, EU) shall be true.
Effects:
If the expression std::forward<T>(t) < std::forward<U>(u) results in a call to a built-in operator < comparing pointers of type P: returns true if (the converted value of) t precedes u in the implementation-defined strict total order over pointers of type P and otherwise false.
Otherwise, equivalent to: return std::forward<T>(t) < std::forward<U>(u);
template <> struct greater_equal<void> {
template <class T, class U>
requires StrictTotallyOrderedWith<T, U> || BUILTIN_PTR_CMP(T, <, U)
constexpr bool operator()(T&& t, U&& u) const;
typedef unspecified is_transparent;
};
operator() has effects equivalent to:
return !less<>{}(std::forward<T>(t), std::forward<U>(u));
template <> struct less_equal<void> {
template <class T, class U>
requires StrictTotallyOrderedWith<T, U> || BUILTIN_PTR_CMP(U, <, T)
constexpr bool operator()(T&& t, U&& u) const;
typedef unspecified is_transparent;
};
operator() has effects equivalent to:
return !less<>{}(std::forward<U>(u), std::forward<T>(t));