The library provides basic function object classes for all of the comparison operators in the language ([expr.rel], [expr.eq]).
template <class T = void> struct equal_to {
constexpr bool operator()(const T& x, const T& y) const;
typedef T first_argument_type;
typedef T second_argument_type;
typedef bool result_type;
};
operator() returns x == y.
template <class T = void> struct not_equal_to {
constexpr bool operator()(const T& x, const T& y) const;
typedef T first_argument_type;
typedef T second_argument_type;
typedef bool result_type;
};
operator() returns x != y.
template <class T = void> struct greater {
constexpr bool operator()(const T& x, const T& y) const;
typedef T first_argument_type;
typedef T second_argument_type;
typedef bool result_type;
};
operator() returns x > y.
template <class T = void> struct less {
constexpr bool operator()(const T& x, const T& y) const;
typedef T first_argument_type;
typedef T second_argument_type;
typedef bool result_type;
};
operator() returns x < y.
template <class T = void> struct greater_equal {
constexpr bool operator()(const T& x, const T& y) const;
typedef T first_argument_type;
typedef T second_argument_type;
typedef bool result_type;
};
operator() returns x >= y.
template <class T = void> struct less_equal {
constexpr bool operator()(const T& x, const T& y) const;
typedef T first_argument_type;
typedef T second_argument_type;
typedef bool result_type;
};
operator() returns x <= y.
template <> struct equal_to<void> {
template <class T, class U> constexpr auto operator()(T&& t, U&& u) const
-> decltype(std::forward<T>(t) == std::forward<U>(u));
typedef unspecified is_transparent;
};
operator() returns std::forward<T>(t) == std::forward<U>(u).
template <> struct not_equal_to<void> {
template <class T, class U> constexpr auto operator()(T&& t, U&& u) const
-> decltype(std::forward<T>(t) != std::forward<U>(u));
typedef unspecified is_transparent;
};
operator() returns std::forward<T>(t) != std::forward<U>(u).
template <> struct greater<void> {
template <class T, class U> constexpr auto operator()(T&& t, U&& u) const
-> decltype(std::forward<T>(t) > std::forward<U>(u));
typedef unspecified is_transparent;
};
operator() returns std::forward<T>(t) > std::forward<U>(u).
template <> struct less<void> {
template <class T, class U> constexpr auto operator()(T&& t, U&& u) const
-> decltype(std::forward<T>(t) < std::forward<U>(u));
typedef unspecified is_transparent;
};
operator() returns std::forward<T>(t) < std::forward<U>(u).
template <> struct greater_equal<void> {
template <class T, class U> constexpr auto operator()(T&& t, U&& u) const
-> decltype(std::forward<T>(t) >= std::forward<U>(u));
typedef unspecified is_transparent;
};
operator() returns std::forward<T>(t) >= std::forward<U>(u).
template <> struct less_equal<void> {
template <class T, class U> constexpr auto operator()(T&& t, U&& u) const
-> decltype(std::forward<T>(t) <= std::forward<U>(u));
typedef unspecified is_transparent;
};
operator() returns std::forward<T>(t) <= std::forward<U>(u).
For templates greater, less, greater_equal, and less_equal, the specializations for any pointer type yield a total order, even if the built-in operators <, >, <=, >= do not.