std::common_comparison_category
cppreference.net에서 가져옴
| 헤더 <compare>
|
||
template< class... Ts >
struct common_comparison_category
{
using type = /* see below */ ;
};
|
에 정의됨 (C++20부터) | |
클래스 템플릿 std::common_comparison_category 은 모든 템플릿 인자 type 가 변환될 수 있는 가장 강력한 비교 범주에 대한 별칭 (멤버 typedef Ts...)을 제공합니다.
자세히는, n개의 타입 목록 T0...Tn-1 의 공통 비교 타입은 다음과 같이 정의됩니다:
- 만약 어떤
Ti 가 비교 범주 타입 (std::partial_ordering, std::weak_ordering, std::strong_ordering)이 아니라면,U는void입니다. - 그렇지 않고, 적어도 하나의
Ti가 std::partial_ordering이면,U는 std::partial_ordering입니다. - 그렇지 않고, 적어도 하나의
Ti가 std::weak_ordering이면,U는 std::weak_ordering입니다. - 그렇지 않으면 (모든
Ti가 std::strong_ordering이거나, 목록이 비어있는 경우),U는 std::strong_ordering입니다.
템플릿 매개변수
| ...Ts | - | 가능한 빈 타입 목록 |
헬퍼 템플릿
|
template
<
class
...
Ts
>
using common_comparison_category_t = common_comparison_category < Ts... > :: type ; |
(C++20 이후) | |
멤버 타입
| 멤버 타입 | 정의 |
type
|
가장 강력한 공통 비교 범주 (위에서 정의된 대로) |
가능한 구현
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; }; } // 네임스페이스 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) )> {}; |
예제
|
이 섹션은 불완전합니다
이유: 예제가 없음 |
참고 항목
|
(C++20)
|
6개의 연산자를 모두 지원하고 대체 가능한 3-way 비교의 결과 타입
(class) |
|
(C++20)
|
6개의 연산자를 모두 지원하지만 대체 불가능한 3-way 비교의 결과 타입
(class) |
|
(C++20)
|
6개의 연산자를 모두 지원하고, 대체 불가능하며, 비교 불가능한 값을 허용하는 3-way 비교의 결과 타입
(class) |