名前空間
変種
操作

std::common_comparison_category

From cppreference.com
< cpp‎ | utility
 
 
ユーティリティライブラリ
言語サポート
型のサポート (基本型、RTTI)
ライブラリ機能検査マクロ (C++20)
プログラムユーティリティ
可変引数関数
コルーチンサポート (C++20)
契約サポート (C++26)
三方比較
common_comparison_category
(C++20)
(C++20)
(C++20)(C++20)(C++20)  
(C++20)(C++20)(C++20)

汎用ユーティリティ
関係演算子 (C++20で非推奨)
 
ヘッダ <compare> で定義
template< class... Ts >

struct common_comparison_category
{
    using type = /* 以下を参照 */ ;

};
(C++20以降)

クラス テンプレート std::common_comparison_category は、すべてのテンプレート引数 Ts... が変換できる最も強力な比較カテゴリのエイリアス(メンバ typedef type として)を提供します。

具体的には、n 個の型 T0...Tn-1 のリストの共通比較型は、次のように定義されます。

目次

[編集] テンプレートパラメータ

...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; };
} // 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)
    )> {};

[編集]

[編集] 関連項目

6つすべての演算子をサポートし、置換可能である三方比較の結果型
(クラス) [編集]
6つすべての演算子をサポートし、置換可能ではない三方比較の結果型
(クラス) [編集]
6つすべての演算子をサポートし、置換可能ではなく、比較不可能な値を許容する三方比較の結果型
(クラス) [編集]
English 日本語 中文(简体) 中文(繁體)