[comparisons.three.way]

# 22 General utilities library [[utilities]](./#utilities)

## 22.10 Function objects [[function.objects]](function.objects#comparisons.three.way)

### 22.10.8 Comparisons [[comparisons]](comparisons#three.way)

#### 22.10.8.8 Class compare_three_way [comparisons.three.way]

[ð](#lib:compare_three_way)

namespace std {struct compare_three_way {template<class T, class U>constexpr auto operator()(T&& t, U&& u) const; using is_transparent = *unspecified*; };}

[ð](#itemdecl:1)

`template<class T, class U>
  constexpr auto operator()(T&& t, U&& u) const;
`

[1](#1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L12553)

*Constraints*: T and U satisfy [three_way_comparable_with](cmp.concept#concept:three_way_comparable_with "17.12.4 Concept three_­way_­comparable [cmp.concept]")[.](#1.sentence-1)

[2](#2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L12557)

*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]](concepts.equality "18.2 Equality preservation"));
otherwise, T and U model [three_way_comparable_with](cmp.concept#concept:three_way_comparable_with "17.12.4 Concept three_­way_­comparable [cmp.concept]")[.](#2.sentence-1)

[3](#3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L12565)

*Effects*: 

- [(3.1)](#3.1)

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]](defns.order.ptr "3.28 implementation-defined strict total order over pointers")), strong_ordering​::​greater if u precedes t, and
 otherwise strong_ordering​::​equal.

- [(3.2)](#3.2)

Otherwise, equivalent to: return std​::​forward<T>(t) <=> std​::​forward<U>(u);
