GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
std::common_comparison_category(3) C++ Standard Libary std::common_comparison_category(3)

std::common_comparison_category - std::common_comparison_category


Defined in header <compare>
template<class... Ts>


struct common_comparison_category { (since C++20)
using type = /*see below*/ ;


};


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::partial_ordering,
std::weak_ordering, std::strong_ordering), U is void.
* Otherwise, 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.


...Ts - a possibly empty list of types


Helper template


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


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


namespace detail {


template<unsigned int>
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


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

2022.07.31 http://cppreference.com

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.