Skip to content

Commit d7d070f

Browse files
committed
multiset : 三方比較演算子の追加と自動導出に対応 #900
1 parent 821ede4 commit d7d070f

11 files changed

+136
-10
lines changed

reference/map/map/op_compare_3way.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ namespace std {
1919
2020
2121
## テンプレートパラメータ制約
22-
- 型 (`const`) `T` の値に対して`operator<=>`が定義されるか、型 (`const`) `T` の値に対して`operator<`が定義され全順序をもつこと
22+
- 型 (`const`) `pair<const Key, T>` の値に対して`operator<=>`が定義されるか、型 (`const`) `pair<const Key, T>` の値に対して`operator<`が定義され全順序をもつこと
2323
2424
2525
## 効果

reference/map/multimap/op_compare_3way.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ namespace std {
1919
2020
2121
## テンプレートパラメータ制約
22-
- 型 (`const`) `T` の値に対して`operator<=>`が定義されるか、型 (`const`) `T` の値に対して`operator<`が定義され全順序をもつこと
22+
- 型 (`const`) `pair<const Key, T>` の値に対して`operator<=>`が定義されるか、型 (`const`) `pair<const Key, T>` の値に対して`operator<`が定義され全順序をもつこと
2323
2424
2525
## 効果

reference/set/multiset.md

+1
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ namespace std {
137137
|-------------------------------------------|--------------------------------------------|-------|
138138
| [`operator==`](multiset/op_equal.md) | 左辺と右辺が等しいかの判定を行う | |
139139
| [`operator!=`](multiset/op_not_equal.md) | 左辺と右辺が等しくないかの判定を行う | |
140+
| [`operator<=>`](multiset/op_compare_3way.md) | 三方比較を行う | C++20 |
140141
| [`operator<`](multiset/op_less.md) | 左辺が右辺より小さいかの判定を行う | |
141142
| [`operator<=`](multiset/op_less_equal.md) | 左辺が右辺より小さいか等しいかの判定を行う | |
142143
| [`operator>`](multiset/op_greater.md) | 左辺が右辺より大きいかの判定を行う | |
+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# operator<=>
2+
* set[meta header]
3+
* std[meta namespace]
4+
* function template[meta id-type]
5+
* cpp20[meta cpp]
6+
7+
```cpp
8+
namespace std {
9+
template <class Key, class Compare, class Allocator>
10+
synth-three-way-result<Key>
11+
operator<=>(const multiset<Key,Compare,Allocator>& x,
12+
const multiset<Key,Compare,Allocator>& y); // (1) C++20
13+
}
14+
```
15+
16+
## 概要
17+
`multiset`オブジェクトの三方比較を行う。
18+
19+
20+
## テンプレートパラメータ制約
21+
- 型 (`const`) `Key` の値に対して`operator<=>`が定義されるか、型 (`const`) `Key` の値に対して`operator<`が定義され全順序をもつこと
22+
23+
24+
## 効果
25+
```cpp
26+
return lexicographical_compare_three_way(
27+
x.begin(), x.end(),
28+
y.begin(), y.end(),
29+
synth-three-way);
30+
```
31+
* lexicographical_compare_three_way[link /reference/algorithm/lexicographical_compare_three_way.md]
32+
* begin()[link begin.md]
33+
* end()[link end.md]
34+
35+
36+
## 計算量
37+
線形時間
38+
39+
40+
## 備考
41+
- この演算子により、以下の演算子が使用可能になる (C++20):
42+
- `operator<`
43+
- `operator<=`
44+
- `operator>`
45+
- `operator>=`
46+
47+
48+
##
49+
```cpp example
50+
#include <cassert>
51+
#include <set>
52+
53+
int main()
54+
{
55+
std::multiset<int> s1, s2;
56+
s1.insert(10);
57+
s1.insert(20);
58+
s1.insert(30);
59+
s2 = s1;
60+
61+
assert((s1 <=> s2) == 0);
62+
63+
s2.insert(40);
64+
65+
assert((s1 <=> s2) != 0);
66+
}
67+
```
68+
* insert[link insert.md]
69+
70+
### 出力
71+
```
72+
```
73+
74+
75+
## 参照
76+
- [P1614R2 The Mothership has Landed](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1614r2.html)
77+
- C++20での三方比較演算子の追加と、関連する演算子の自動導出

reference/set/multiset/op_equal.md

+10-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
```cpp
77
namespace std {
88
template <class Key, class Compare, class Allocator>
9-
bool operator==(const multiset<Key,Compare,Allocator>& x, const multiset<Key,Compare,Allocator>& y);
9+
bool
10+
operator==(const multiset<Key,Compare,Allocator>& x,
11+
const multiset<Key,Compare,Allocator>& y); // (1) C++03
1012
}
1113
```
1214
@@ -23,6 +25,11 @@ namespace std {
2325
[`size()`](size.md) に対して線形時間。ただし、`x`と`y`のサイズが異なる場合は定数時間。
2426
2527
28+
## 備考
29+
- この演算子により、以下の演算子が使用可能になる (C++20):
30+
- `operator!=`
31+
32+
2633
## 例
2734
```cpp example
2835
#include <iostream>
@@ -56,4 +63,5 @@ int main()
5663
## 参照
5764
- [LWG Issue 2257. Simplify container requirements with the new algorithms](http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2257)
5865
- C++14から、2つ目の範囲のendイテレータをとる`equal()`アルゴリズムを使用するようになった。
59-
66+
- [P1614R2 The Mothership has Landed](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1614r2.html)
67+
- C++20での三方比較演算子の追加と、関連する演算子の自動導出

reference/set/multiset/op_greater.md

+9-1
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@
55

66
```cpp
77
namespace std {
8+
// operator<=>により、以下の演算子が使用可能になる (C++20)
89
template <class Key, class Compare, class Allocator>
9-
bool operator> (const multiset<Key,Compare,Allocator>& x, const multiset<Key,Compare,Allocator>& y);
10+
bool
11+
operator>(const multiset<Key,Compare,Allocator>& x,
12+
const multiset<Key,Compare,Allocator>& y); // (1) C++03
1013
}
1114
```
1215
@@ -55,3 +58,8 @@ int main()
5558
0
5659
1
5760
```
61+
62+
63+
## 参照
64+
- [P1614R2 The Mothership has Landed](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1614r2.html)
65+
- C++20での三方比較演算子の追加と、関連する演算子の自動導出

reference/set/multiset/op_greater_equal.md

+9-1
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@
55

66
```cpp
77
namespace std {
8+
// operator<=>により、以下の演算子が使用可能になる (C++20)
89
template <class Key, class Compare, class Allocator>
9-
bool operator>=(const multiset<Key,Compare,Allocator>& x, const multiset<Key,Compare,Allocator>& y);
10+
bool
11+
operator>=(const multiset<Key,Compare,Allocator>& x,
12+
const multiset<Key,Compare,Allocator>& y); // (1) C++03
1013
}
1114
```
1215
@@ -55,3 +58,8 @@ int main()
5558
1
5659
0
5760
```
61+
62+
63+
## 参照
64+
- [P1614R2 The Mothership has Landed](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1614r2.html)
65+
- C++20での三方比較演算子の追加と、関連する演算子の自動導出

reference/set/multiset/op_less.md

+9-1
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@
55

66
```cpp
77
namespace std {
8+
// operator<=>により、以下の演算子が使用可能になる (C++20)
89
template <class Key, class Compare, class Allocator>
9-
bool operator< (const multiset<Key,Compare,Allocator>& x, const multiset<Key,Compare,Allocator>& y);
10+
bool
11+
operator<(const multiset<Key,Compare,Allocator>& x,
12+
const multiset<Key,Compare,Allocator>& y); // (1) C++03
1013
}
1114
```
1215
@@ -53,3 +56,8 @@ int main ()
5356
```
5457
true
5558
```
59+
60+
61+
## 参照
62+
- [P1614R2 The Mothership has Landed](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1614r2.html)
63+
- C++20での三方比較演算子の追加と、関連する演算子の自動導出

reference/set/multiset/op_less_equal.md

+9-1
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@
55

66
```cpp
77
namespace std {
8+
// operator<=>により、以下の演算子が使用可能になる (C++20)
89
template <class Key, class Compare, class Allocator>
9-
bool operator<=(const multiset<Key,Compare,Allocator>& x, const multiset<Key,Compare,Allocator>& y);
10+
bool
11+
operator<=(const multiset<Key,Compare,Allocator>& x,
12+
const multiset<Key,Compare,Allocator>& y); // (1) C++03
1013
}
1114
```
1215
@@ -55,3 +58,8 @@ int main()
5558
1
5659
0
5760
```
61+
62+
63+
## 参照
64+
- [P1614R2 The Mothership has Landed](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1614r2.html)
65+
- C++20での三方比較演算子の追加と、関連する演算子の自動導出

reference/set/multiset/op_not_equal.md

+9-1
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@
55

66
```cpp
77
namespace std {
8+
// operator==により、以下の演算子が使用可能になる (C++20)
89
template <class Key, class Compare, class Allocator>
9-
bool operator!=(const multiset<Key,Compare,Allocator>& x, const multiset<Key,Compare,Allocator>& y);
10+
bool
11+
operator!=(const multiset<Key,Compare,Allocator>& x,
12+
const multiset<Key,Compare,Allocator>& y); // (1) C++03
1013
}
1114
```
1215
@@ -55,3 +58,8 @@ int main()
5558
0
5659
1
5760
```
61+
62+
63+
## 参照
64+
- [P1614R2 The Mothership has Landed](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1614r2.html)
65+
- C++20での三方比較演算子の追加と、関連する演算子の自動導出

reference/set/set/op_compare_3way.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ namespace std {
1818
1919
2020
## テンプレートパラメータ制約
21-
- 型 (`const`) `T` の値に対して`operator<=>`が定義されるか、型 (`const`) `T` の値に対して`operator<`が定義され全順序をもつこと
21+
- 型 (`const`) `Key` の値に対して`operator<=>`が定義されるか、型 (`const`) `Key` の値に対して`operator<`が定義され全順序をもつこと
2222
2323
2424
## 効果

0 commit comments

Comments
 (0)