std:: common_comparison_category
|
ヘッダーで定義
<compare>
|
||
|
template
<
class
...
Ts
>
struct
common_comparison_category
|
(C++20以降) | |
クラステンプレート
std::common_comparison_category
は、すべてのテンプレート引数
Ts...
が変換可能な最も強い比較カテゴリに対するエイリアス(メンバ型
type
として)を提供します。
詳細には、n個の型のリスト
T
0
...
T
n-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つの演算子をサポートし、置換可能な3方向比較の結果型
(class) |
|
(C++20)
|
すべての6つの演算子をサポートし、置換不可能な3方向比較の結果型
(class) |
|
(C++20)
|
すべての6つの演算子をサポートし、置換不可能で、比較不能な値を許容する3方向比較の結果型
(class) |