operator==,!=,<,<=,>,>=,<=>(std::multiset)
提供: cppreference.com
ヘッダ <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 > /* see below */ operator<=>( const std::multiset<Key,Compare,Alloc>& lhs, |
(7) | (C++20以上) |
2つの multiset
の内容を比較します。
1-2)
lhs
と rhs
の内容が等しいかどうか調べます。 つまり、それらが同じ個数の要素を持ち、 lhs
内のそれぞれの要素が rhs
内の同じ位置の要素と等しいかどうか比較します。3-6)
lhs
と rhs
の内容を辞書的に比較します。 比較は std::lexicographical_compare と同等の関数によって行われます。 この比較は multiset
の順序 Compare を無視します。7)
lhs
と rhs
の内容を辞書的に比較します。 比較は合成された三項比較 (後述) を行う関数オブジェクトを用いて2つの multiset
に対して std::lexicographical_compare_three_way を呼んだかのように行われます。 戻り値の型は合成された三項比較の結果の型と同じです。 この比較は multiset
の順序 Compare を無視します。 2つの const E 左辺値 lhs
および rhs
がそれぞれ左の被演算子および右の被演算子として与えられたとき (ただし E
は Key
です)、合成された三項比較は以下のように定義されます。
- std::three_way_comparable_with<E, E> が満たされる場合は、 lhs <=> rhs と同等です。
- そうでなく、2つの const E 左辺値の < 演算子による比較が well-formed であり結果の型が
boolean-testable
の場合は、以下と同等です。
lhs < rhs ? std::weak_ordering::less : rhs < lhs ? std::weak_ordering::greater : std::weak_ordering::equivalent
- そうでなければ、合成された三項比較は定義されず、 operator<=> はオーバーロード解決に参加しません。
boolean-testable
が満たされないかモデル化されない場合、または < 演算子が使用されるけれども E
と <
が全順序を確立しない場合、 operator<=> の動作は未定義です。[編集] 引数
lhs, rhs | - | 内容を比較する multiset
|
-オーバロード (1-2) を使用するためには Key は EqualityComparable の要件を満たさなければなりません。
|
[編集] 戻り値
1)
multiset
の内容が等しい場合は true、そうでなければ false。2)
multiset
の内容が等しくない場合は true、そうでなければ false。3)
lhs
の内容が rhs
の内容より辞書的に小さい場合は true、そうでなければ false。4)
lhs
の内容が rhs
の内容より辞書的に小さいまたは等しい場合は true、そうでなければ false。5)
lhs
の内容が rhs
の内容より辞書的に大きい場合は true、そうでなければ false。6)
lhs
の内容が rhs
の内容より辞書的に大きいまたは等しい場合は true、そうでなければ false。7)
そうでなければ std::strong::equal。
lhs
の内容が rhs
の内容より辞書的に小さい場合は std::strong_ordering::less、lhs
の内容が rhs
の内容より辞書的に大きい場合は std::strong_ordering::greater、lhs
と rhs
の同等でない最初の要素が順序付けできない場合は std::partial_ordering::unordered、そうでなければ std::strong::equal。
[編集] 計算量
1-2)
lhs
と rhs
のサイズが異なる場合は定数、そうでなければ multiset
のサイズに線形3-7)
multiset
のサイズに線形