std::common_comparison_category
ja.cppreference.net より
| ヘッダ <compare>
|
||
template< class... Ts >
struct common_comparison_category
{
using type = /* see below */ ;
};
|
(C++20以上) で定義される | |
クラステンプレート std::common_comparison_category は、テンプレート引数 type のすべてを変換可能な最も強い比較カテゴリのエイリアス(メンバ型 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; }; } // 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) |