17 Language support library [language.support]

17.11 Comparisons [cmp]

17.11.6 Class compare_­three_­way [cmp.object]

In this subclause, BUILTIN-PTR-THREE-WAY(T, U) for types T and U is a boolean constant expression.
BUILTIN-PTR-THREE-WAY(T, U) is true if and only if <=> in the expression
declval<T>() <=> declval<U>()
resolves to a built-in operator comparing pointers.
struct compare_three_way {
  template<class T, class U>
    requires three_way_comparable_with<T, U> || BUILTIN-PTR-THREE-WAY(T, U)
  constexpr auto operator()(T&& t, U&& u) const;

  using is_transparent = unspecified;
};
In addition to being available via inclusion of the <compare> header, the class compare_­three_­way is available when the header <functional> ([functional.syn]) is included.
template<class T, class U> requires three_way_comparable_with<T, U> || BUILTIN-PTR-THREE-WAY(T, U) constexpr auto operator()(T&& t, U&& u) const;
Preconditions: 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 are equality-preserving ([concepts.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 strong_­ordering​::​less if (the converted value of) t precedes u in the implementation-defined strict total order over pointers ([defns.order.ptr]), strong_­ordering​::​greater if u precedes t, and otherwise strong_­ordering​::​equal.
  • Otherwise, equivalent to: return std​::​forward<T>(t) <=> std​::​forward<U>(u);