std::common_comparison_category
From cppreference.com
| ヘッダ <compare> で定義 |
||
| template< class... Ts > struct common_comparison_category |
(C++20以降) | |
クラス テンプレート std::common_comparison_category は、すべてのテンプレート引数 Ts... が変換できる最も強力な比較カテゴリのエイリアス(メンバ typedef type として)を提供します。
具体的には、n 個の型 T0...Tn-1 のリストの共通比較型は、次のように定義されます。
- いずれかの
Ti が比較カテゴリ型(std::partial_ordering、std::weak_ordering、std::strong_ordering)でない場合、Uは void です。 - そうでなく、少なくとも1つの
Ti が std::partial_ordering の場合、Uは std::partial_ordering です。 - そうでなく、少なくとも1つの
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; }; } // 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) )> {}; |
[編集] 例
| このセクションは未完成です 理由: 例がありません |
[編集] 関連項目
| (C++20) |
6つすべての演算子をサポートし、置換可能である三方比較の結果型 (クラス) |
| (C++20) |
6つすべての演算子をサポートし、置換可能ではない三方比較の結果型 (クラス) |
| (C++20) |
6つすべての演算子をサポートし、置換可能ではなく、比較不可能な値を許容する三方比較の結果型 (クラス) |