[compare.type]

# 17 Language support library [[support]](./#support)

## 17.12 Comparisons [[cmp]](cmp#compare.type)

### 17.12.7 Type Ordering [compare.type]

[1](#1)

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

There is an implementation-defined total ordering of all types[.](#1.sentence-1)

For any (possibly incomplete) types X and Y,
the expression *TYPE-ORDER*(X, Y) is a constant expression ([[expr.const]](expr.const "7.7 Constant expressions"))
of type strong_ordering ([[cmp.strongord]](cmp.strongord "17.12.2.4 Class strong_­ordering"))[.](#1.sentence-2)

Its value is strong_ordering​::​less if X precedes Y in this implementation-defined total order,strong_ordering​::​greater if Y precedes X, andstrong_ordering​::​equal if they are the same type[.](#1.sentence-3)

[*Note [1](#note-1)*:

int, const int and int& are different types[.](#1.sentence-4)

â *end note*]

[*Note [2](#note-2)*:

This ordering need not be consistent with the one induced by type_info​::​before[.](#1.sentence-5)

â *end note*]

[*Note [3](#note-3)*:

The ordering of TU-local types from different translation units is not observable,
because the necessary specialization of type_order is impossible to name[.](#1.sentence-6)

â *end note*]

[ð](#lib:type_order)

`template<class T, class U>
  struct type_order;
`

[2](#2)

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

The name type_order denotes a *Cpp17BinaryTypeTrait* ([[meta.rqmts]](meta.rqmts "21.3.2 Requirements"))
with a base characteristic ofintegral_constant<strong_ordering, *TYPE-ORDER*(T, U)>[.](#2.sentence-1)

[3](#3)

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

*Recommended practice*: The order should be lexicographical on parameter-type-lists and template argument lists[.](#3.sentence-1)
