17 Language support library [support]

17.12 Comparisons [cmp]

17.12.7 Type Ordering [compare.type]

There is an implementation-defined total ordering of all types.
For any (possibly incomplete) types X and Y, the expression TYPE-ORDER(X, Y) is a constant expression ([expr.const]) of type strong_ordering ([cmp.strongord]).
Its value is strong_ordering​::​less if X precedes Y in this implementation-defined total order, strong_ordering​::​greater if Y precedes X, and strong_ordering​::​equal if they are the same type.
[Note 1: 
int, const int and int& are different types.
— end note]
[Note 2: 
This ordering need not be consistent with the one induced by type_info​::​before.
— end note]
[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.
— end note]
template<class T, class U> struct type_order { static constexpr strong_ordering value = TYPE-ORDER(T, U); using value_type = strong_ordering; constexpr operator value_type() const noexcept { return value; } constexpr value_type operator()() const noexcept { return value; } };
If an explicit specialization or partial specialization of type_order is declared, the program is ill-formed.
Recommended practice: The order should be lexicographical on parameter-type-lists and template argument lists.
Morty Proxy This is a proxified and sanitized view of the page, visit original site.