std::strong_order
| ヘッダ <compare>
|
||
inline namespace /* unspecified */ {
inline constexpr /* unspecified */ strong_order = /* unspecified */;
}
|
で定義 (C++20以降) | |
| 呼び出しシグネチャ |
||
template< class T, class U >
requires /* see below */
constexpr std::strong_ordering strong_order( T&& t, U&& u ) noexcept(/* see below */);
|
||
三方比較を使用して2つの値を比較し、型std::strong_orderingの結果を生成します。
t と u を式とし、T と U でそれぞれ decltype((t)) と decltype((u)) を表すものとすると、std::strong_order(t, u) は次の式と等価(expression-equivalent)です:
std::is_same_v<std::decay_t<T>, std::decay_t<U>>がtrueの場合:std::strong_ordering(strong_order(t, u))(std::strong_orderの宣言を含まないコンテキストでオーバーロード解決が行われ、それが適格な式である場合)- それ以外の場合、
Tが浮動小数点型である場合:std::numeric_limits<T>::is_iec559がtrueである場合、浮動小数点値の ISO/IEC/IEEE 60559 totalOrder 比較を実行し、その結果を std::strong_ordering 型の値として返します(注: この比較は、正のゼロと負のゼロ、および異なる表現の NaN を区別できます)、- それ以外の場合、std::strong_ordering 型の値を生成します。この値は、
Tの比較演算子によって観測される順序と一貫性があります。
- それ以外の場合、それが適格であれば
std::strong_ordering(std::compare_three_way()(t, u))を使用します。
- その他すべての場合、式は不適格となり、テンプレートのインスタンス化の即時コンテキストに現れた場合、置換失敗を引き起こす可能性があります。
カスタマイゼーションポイントオブジェクト
名前
std::strong_order
は
カスタマイゼーションポイントオブジェクト
を表し、これは
関数オブジェクト
のconstな
リテラル
semiregular
クラス型である。詳細は
CustomizationPointObject
を参照。
IEEE浮動小数点型の厳密な全順序
x と y を同じIEEE浮動小数点型の値とし、 total_order_less ( x, y ) を、ISO/IEC/IEEE 60559の totalOrder によって定義される厳密な全順序において x が y に先行するかどうかを示すブーリアン結果とする。
( total_order_less ( x, y ) || total_order_less ( y, x ) ) == false が成り立つのは、 x と y が同じビットパターンを持つ場合に限ります。
-
x
も
y
もNaNでない場合:
- x < y の場合、 total_order_less ( x, y ) == true となる;
- x > y の場合、 total_order_less ( x, y ) == false となる;
-
x
==
y
の場合、
- x が負のゼロで y が正のゼロの場合、 total_order_less ( x, y ) == true となる、
- x がゼロでなく、かつ x の指数部が y の指数部より小さい場合、 total_order_less ( x, y ) == ( x > 0 ) となる(十進浮動小数点数でのみ意味を持つ);
-
x
または
y
のいずれかがNaNの場合:
- x が負のNaNで y が負のNaNでない場合、 total_order_less ( x, y ) == true となる、
- x が正のNaNでなく、かつ y が正のNaNの場合、 total_order_less ( x, y ) == true となる、
- x と y が同じ符号のNaNで、かつ x の仮数部が y の仮数部より小さい場合、 total_order_less ( x, y ) == ! std:: signbit ( x ) となる。
例
|
このセクションは不完全です
理由: 例がありません |
関連項目
|
(C++20)
|
すべての6つの演算子をサポートし、置換可能な3方向比較の結果型
(クラス) |
|
(C++20)
|
3方向比較を実行し、型
std::weak_ordering
の結果を生成する
(カスタマイゼーションポイントオブジェクト) |
|
(C++20)
|
3方向比較を実行し、型
std::partial_ordering
の結果を生成する
(カスタマイゼーションポイントオブジェクト) |
|
(C++20)
|
3方向比較を実行し、型
std::strong_ordering
の結果を生成する(
operator
<=>
が利用できない場合でも)
(カスタマイゼーションポイントオブジェクト) |