# std::common_comparison_category

From cppreference.com
< cpp‎ | utility

Defined in header `<compare>` |  |
template<class... Ts> struct common_comparison_category { using type = /*see below*/ ; }; |  | (since C++20)

The class template `std::common_comparison_category` provides an alias (as the member typedef `type`) for the strongest comparison category to which all of the template arguments `Ts...` can be converted.

In detail, the common comparison type of a list of n types T0...Tn-1 is defined as follows:

- If any Ti is not a comparison category type (`std::weak_equality`, `std::strong_equality`, `std::partial_ordering`, `std::weak_ordering`, `std::strong_ordering`), U is void.
- Otherwise, if at least one Ti is `std::weak_equality` or at least one Ti is `std::strong_equality` and at least one Ti is `std::partial_ordering` or `std::weak_ordering`, U is `std::weak_equality`
- Otherwise, if at least one Ti is `std::strong_equality`, U is `std::strong_equality`
- Otherwise, (if there is no `std::weak_equality` and no `std::strong_equality`) if at least one Ti is `std::partial_ordering`, U is `std::partial_ordering`
- Otherwise, if at least one Ti is `std::weak_ordering`, U is `std::weak_ordering`
- Otherwise (if every Ti is `std::strong_ordering`, or if the list is empty), U is `std::strong_ordering`.

### Template parameters

...Ts | - | a possibly empty list of types

### Helper template

template< class... Ts > using common_comparison_category_t = typename common_comparison_category<Ts...>::type; |  | (since C++20)

### Member types

Member type | Definition
`type` | the strongest common comparison category (as defined above)

### Example

| This section is incomplete Reason: no example

### See also

strong_ordering (C++20) | the result type of 3-way comparison that supports all 6 operators and is substitutable (class)
weak_ordering (C++20) | the result type of 3-way comparison that supports all 6 operators and is not substitutable (class)
partial_ordering (C++20) | the result type of 3-way comparison that supports all 6 operators, is not substitutable, and allows incomparable values (class)
strong_equality (C++20) | the result type of 3-way comparison that supports only equality/inequality and is substitutable (class)
weak_equality (C++20) | the result type of 3-way comparison that supports only equality/inequality and is not substitutable (class)

Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/utility/compare/common_comparison_category&oldid=105533"