operator==,!=,<,<=,>,>=,<=> (std::multiset)
|
ヘッダーで定義
<set>
|
||
|
template
<
class
Key,
class
Compare,
class
Alloc
>
bool
operator
==
(
const
std::
multiset
<
Key, Compare, Alloc
>
&
lhs,
|
(1) | (C++26以降 constexpr) |
|
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
>
/* 以下を参照 */
|
(7) |
(C++20以降)
(C++26以降 constexpr) |
2つの
multiset
の内容を比較します。
value_type
を
multiset
の値型(すなわち、
typename
multiset
::
value_type
)とします:
|
return
std::
distance
(
lhs.
begin
(
)
, lhs.
end
(
)
)
|
(C++14まで) |
|
return std:: equal ( lhs. begin ( ) , lhs. end ( ) , rhs. begin ( ) , rhs. end ( ) ) ; |
(C++14から) |
rhs. begin ( ) , rhs. end ( ) ) ; に相当します。
-
value_typeが LessThanComparable ではない場合。 - operator < が 全順序 を確立しない場合。
rhs.
begin
(
)
, rhs.
end
(
)
,
synth-three-way
)
。
-
Tがthree_way_comparableをモデルにしていない場合。 -
operator
<
が(const修飾された可能性のある)
value_type型の値に対して定義されていない場合。 - operator < が 全順序 を確立しない場合。
|
|
(C++20以降) |
目次 |
パラメータ
| lhs, rhs | - |
multiset
比較対象の内容を持つセット
|
戻り値
| 演算子 |
lhs
と
rhs
が等しい場合 |
lhs
が
辞書順で大きい場合 |
rhs
が
辞書順で大きい場合 |
|---|---|---|---|
| operator == | true | false | |
| operator ! = | false | true | |
| operator < | false | false | true |
| operator <= | true | ||
| operator > | false | true | false |
| operator >= | true | ||
| operator <=> | 0に等しい値 | 0より大きい値 | 0より小さい値 |
計算量
multiset
のサイズに対して線形時間。
multiset
。
注記
|
関係演算子は
|
(C++20まで) |
|
関係演算子は定義されません。書き換え候補である operator <=> がオーバーロード解決によって選択されます。
operator
<=>
は可能な場合
|
(C++20以降) |
これらの非メンバ比較演算子は、要素を比較するために
Compare
を使用しません。
例
#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
をモデル化することを要求していなかった
|
要求する |