|
|
Defined in header <compare> | ||
template<class...Ts> struct common_comparison_category | (since C++20) | |
The class templatestd::common_comparison_category
provides an alias (as the member typedeftype
) for the strongest comparison category to which all of the template argumentsTs...
can be converted.
In detail, the common comparison type of a list of n typesT
0...T
n-1 is defined as follows:
T
i is not a comparison category type (std::partial_ordering,std::weak_ordering,std::strong_ordering),U
isvoid.T
i isstd::partial_ordering,U
isstd::partial_ordering.T
i isstd::weak_ordering,U
isstd::weak_ordering.T
i isstd::strong_ordering, or if the list is empty),U
isstd::strong_ordering.Contents |
...Ts | - | a possibly empty list of types |
template<class...Ts> using common_comparison_category_t= common_comparison_category<Ts...>::type; | (since C++20) | |
Member type | Definition |
type | the strongest common comparison category (as defined above) |
namespace detail{template<unsignedint>struct common_cmpcat_base{using type=void;};template<>struct common_cmpcat_base<0u>{using type=std::strong_ordering;};template<>struct common_cmpcat_base<2u>{using type=std::partial_ordering;};template<>struct common_cmpcat_base<4u>{using type=std::weak_ordering;};template<>struct common_cmpcat_base<6u>{using type=std::partial_ordering;};}// namespace detail template<class...Ts>struct common_comparison_category: detail::common_cmpcat_base<(0u| ...|(std::is_same_v<Ts,std::strong_ordering>? 0u:std::is_same_v<Ts,std::weak_ordering>? 4u:std::is_same_v<Ts,std::partial_ordering>? 2u: 1u))>{}; |
This section is incomplete Reason: no example |
(C++20) | the result type of 3-way comparison that supports all 6 operators and is substitutable (class)[edit] |
(C++20) | the result type of 3-way comparison that supports all 6 operators and is not substitutable (class)[edit] |
(C++20) | the result type of 3-way comparison that supports all 6 operators, is not substitutable, and allows incomparable values (class)[edit] |