operator==,!=,<,<=,>,>=,<=>(std::multiset)
| ヘッダー <set> で定義 |
||
| template< class Key, class Compare, class Alloc > bool operator==( const std::multiset<Key, Compare, Alloc>& lhs, |
(1) | |
| template< class Key, class Compare, class Alloc > bool operator!=( const std::multiset<Key, Compare, Alloc>& lhs, |
(2) | (C++20まで) |
| template< class Key, class Compare, class Alloc > bool operator<( const std::multiset<Key, Compare, Alloc>& lhs, |
(3) | (C++20まで) |
| template< class Key, class Compare, class Alloc > bool operator<=( const std::multiset<Key, Compare, Alloc>& lhs, |
(4) | (C++20まで) |
| template< class Key, class Compare, class Alloc > bool operator>( const std::multiset<Key, Compare, Alloc>& lhs, |
(5) | (C++20まで) |
| template< class Key, class Compare, class Alloc > bool operator>=( const std::multiset<Key, Compare, Alloc>& lhs, |
(6) | (C++20まで) |
| template< class Key, class Compare, class Alloc > synth-three-way-result<T> |
(7) | (C++20以降) |
2つのmultisetの内容を比較します。
multiset の順序付け Compare は無視されます。 rhs.begin(), rhs.end(), synth-three-way) を呼び出すかのように行われます。この比較では、multiset の順序付け Compare は無視されます。-
Tはthree_way_comparableのモデルです。 - 型(おそらくconst修飾された)
Tの値に対して<が定義されており、<は全順序関係です。
|
|
(C++20以降) |
目次 |
[編集] パラメータ
| lhs, rhs | - | 比較するmultiset |
-オーバーロード (1, 2) を使用するためには、Key は EqualityComparable の要件を満たす必要があります。 | ||
[編集] 戻り値
multiset の内容が等しい場合は true、そうでない場合は false。multiset の内容が等しくない場合は true、そうでない場合は false。[編集] 計算量
multiset のサイズに線形時間。multiset のサイズに線形時間。[編集] 備考
|
関係演算子は、要素型のoperator<を介して定義されます。 |
(C++20まで) |
|
関係演算子はsynth-three-wayを介して定義されます。synth-three-wayは、可能であればoperator<=>を使用し、そうでなければoperator<を使用します。 特に、要素自身がoperator<=>を提供しないが、三方比較可能な型に暗黙的に変換できる場合、その変換がoperator<の代わりに使用されます。 |
(C++20以降) |
[編集] 例
#include <cassert> #include <compare> #include <set> int main() { const std::multiset a{1, 2, 3}, b{1, 2, 3}, c{7, 8, 9, 10}; assert ("" "Compare equal containers:" && (a != b) == false && (a == b) == true && (a < b) == false && (a <= b) == true && (a > b) == false && (a >= b) == true && (a <=> b) != std::weak_ordering::less && (a <=> b) != std::weak_ordering::greater && (a <=> b) == std::weak_ordering::equivalent && (a <=> b) >= 0 && (a <=> b) <= 0 && (a <=> b) == 0 && "Compare non equal containers:" && (a != c) == true && (a == c) == false && (a < c) == true && (a <= c) == true && (a > c) == false && (a >= c) == false && (a <=> c) == std::weak_ordering::less && (a <=> c) != std::weak_ordering::equivalent && (a <=> c) != std::weak_ordering::greater && (a <=> c) < 0 && (a <=> c) != 0 && (a <=> c) <= 0 && ""); }
[編集] 欠陥報告
以下の動作変更を伴う欠陥報告が、以前に公開されたC++標準に遡って適用されました。
| DR | 適用対象 | 公開された動作 | 正しい動作 |
|---|---|---|---|
| LWG 3431 | C++20 | operator<=>はTを必要としませんでしたthree_way_comparableのモデルとするために |
要求するようになった |