Namespaces
Variants

std::type_order

From cppreference.com
 
 
Utilities library
General utilities
Relational operators (deprecated in C++20)
Integer comparison functions
(C++20)(C++20)(C++20)    
(C++20)
Swap and type operations
(C++14)
(C++11)
(C++11)
(C++11)
(C++17)
Common vocabulary types
(C++11)
(C++17)
(C++17)
(C++17)
(C++11)
(C++17)
(C++23)



 
Defined in header <compare>
template< class T, class U >
struct type_order;
(since C++26)

Implements an implementation-defined total ordering of all types.

Provides the member constant value equal to std::strong_ordering::less if T precedes U in this implementation-defined total order, std::strong_ordering::greater if U precedes T, and std::strong_ordering::equal if they are the same type.

This ordering need not be consistent with the one induced by std::type_info::before.

The template arguments T and U can be incomplete types.

If the program adds specializations for std::type_order or std::type_order_v, the program is ill-formed.

Helper variable template

template< class T, class U >
constexpr std::strong_ordering type_order_v = type_order<T, U>::value;
(since C++26)

Member constants

value
[static]
a value of type std::strong_ordering, as described above
(public static member constant)

Member functions

operator std::strong_ordering
converts the object to std::strong_ordering, returns value
(public member function)
operator()
returns value
(public member function)

Member types

Type Definition
value_type std::strong_ordering

Notes

Feature-test macro Value Std Feature
__cpp_lib_type_order 202506L (C++26) std::type_order, std::type_order_v

Example

See also

the result type of 3-way comparison that supports all 6 operators and is substitutable
(class) [edit]