2
2
<feed xmlns =" http://www.w3.org/2005/Atom" >
3
3
<title >cpprefjp - C++日本語リファレンス</title >
4
4
<link href =" https://cpprefjp.github.io" />
5
- <updated >2025-05-28T05:53:12.456076 </updated >
6
- <id >2a530736-59f8-414a-b9d8-fdc077fcf0f8 </id >
5
+ <updated >2025-05-28T08:12:47.331200 </updated >
6
+ <id >f937898e-adf5-4853-aff3-775a76ffa979 </id >
7
7
8
8
9
+ <entry >
10
+ <title >allocator -- allocator : C++26対応としてis_always_equalを削除 (close #1242)</title >
11
+ <link href =" https://cpprefjp.github.io/reference/memory/allocator.html" />
12
+ <id >c3e97ea8a80e4a22e82c6b943a35492f2894d99e:reference/memory/allocator.md</id >
13
+ <updated >2025-05-28T17:09:01+09:00</updated >
14
+
15
+ <summary type =" html" >< pre>< code> diff --git a/reference/memory/allocator.md b/reference/memory/allocator.md
16
+ index f38eef148..7d9970fe2 100644
17
+ --- a/reference/memory/allocator.md
18
+ +++ b/reference/memory/allocator.md
19
+ @@ -64,7 +64,7 @@ C++11から:
20
+ | `reference` | 要素の参照型 `T& amp;` | C++17から非推奨& lt;br/& gt; C++20で削除 |
21
+ | `const_reference` | 読み取り専用の要素の参照型 `const T& amp;` | C++17から非推奨& lt;br/& gt; C++20で削除 |
22
+ | `rebind& lt;U& gt;` | 型`U`を確保するように再束縛する | C++17から非推奨& lt;br/& gt; C++20で削除 |
23
+ -| `is_always_equal` | 同じ型のアロケータオブジェクトが2つある場合、それらが常に同値であるか。[`true_type`](/reference/type_traits/true_type.md) | C++17 |
24
+ +| `is_always_equal` | 同じ型のアロケータオブジェクトが2つある場合、それらが常に同値であるか。[`true_type`](/reference/type_traits/true_type.md) | C++17& lt;br/& gt; C++20で非推奨& lt;br/& gt; C++26で削除 |
25
+
26
+
27
+ ## 非メンバ関数
28
+ @@ -87,6 +87,9 @@ C++11から:
29
+ - なお、プライマリテンプレートからインスタンス化されるようになっても`allocate`/`deallocate`メンバは内部で`sizeof(void)`を要求するため引き続き使用不可能であり、`std::allocator& lt;void& gt;`の使用用途としては従来と同じく再束縛を目的とすることになる(上述のように[`std::allocator_traits`](allocator_traits.md)の代替機能を用いて`typename` [`std::allocator_traits`](allocator_traits.md)`& lt;std::allocator& lt;void& gt;& gt;::template rebind_alloc& lt;R& gt;`のようにする)。
30
+
31
+ - メンバ型の`size_type`と`difference_type`は、C++17で非推奨となったがC++20で非推奨が取り消された。
32
+ +- メンバ型の`is_always_equal`は、このクラスを継承したメモリアロケータが`is_always_equal`の値を引き継いでしまうという点で問題があったため、C++20で非推奨となり、C++26で削除された。
33
+ + - 代わりに[`std::allocator_traits`](allocator_traits.md)クラスの`is_always_equal`メンバ型を使用すること。
34
+ +
35
+
36
+ ## 例
37
+ ```cpp example
38
+ @@ -140,3 +143,7 @@ int main(int argc, char** argv) {
39
+ - [P0174R2 Deprecating Vestigial Library Parts in C++17](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0174r2.html)
40
+ - [P0619R4 Reviewing deprecated facilities of C++17 for C++20](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0619r4.html)
41
+ - [N4258 Cleaning-up noexcept in the Library, Rev 3](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4258.pdf)
42
+ +- [LWG Issue 3170. `is_always_equal` added to `std::allocator` makes the standard library treat derived types as always equal](https://cplusplus.github.io/LWG/issue3170)
43
+ + - C++20で`is_always_equal`メンバ型が非推奨化された
44
+ +- [P2868R3 Remove Deprecated `std::allocator` Typedef From C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2023/p2868r3.pdf)
45
+ + - C++26で`is_always_equal`メンバ型が削除された
46
+ < /code>< /pre> </summary >
47
+
48
+ <author >
49
+ <name >Akira Takahashi</name >
50
+
51
+ </author >
52
+ </entry >
53
+
9
54
<entry >
10
55
<title >projected -- projected : C++26での不完全型への対策に対応 (close #1185)</title >
11
56
<link href =" https://cpprefjp.github.io/reference/iterator/projected.html" />
@@ -953,228 +998,4 @@ index 2c418690b..89531d1fd 100644
953
998
</author >
954
999
</entry >
955
1000
956
- <entry >
957
- <title >count -- ranges::count, equal_range, lower_bound : 射影変換の例を追加</title >
958
- <link href =" https://cpprefjp.github.io/reference/algorithm/ranges_count.html" />
959
- <id >1f87d6a9e341dd8e5fe7a0f74d7545a804e9895a:reference/algorithm/ranges_count.md</id >
960
- <updated >2025-05-27T17:23:04+09:00</updated >
961
-
962
- <summary type =" html" >< pre>< code> diff --git a/reference/algorithm/ranges_count.md b/reference/algorithm/ranges_count.md
963
- index 0c3504815..294f0855b 100644
964
- --- a/reference/algorithm/ranges_count.md
965
- +++ b/reference/algorithm/ranges_count.md
966
- @@ -142,6 +142,43 @@ int main() {
967
- count of {1,2}: 2
968
- ```
969
-
970
- +### 射影変換を使用した例
971
- +```cpp example
972
- +#include & lt;algorithm& gt;
973
- +#include & lt;iostream& gt;
974
- +#include & lt;vector& gt;
975
- +#include & lt;string& gt;
976
- +
977
- +struct Item {
978
- + int id;
979
- + std::string label;
980
- +};
981
- +
982
- +int main() {
983
- + std::vector& lt;Point& gt; v = {
984
- + {1, & #34;foo& #34;},
985
- + {3, & #34;bar& #34;},
986
- + {5, & #34;foo& #34;},
987
- + {2, & #34;baz& #34;},
988
- + };
989
- +
990
- + // メンバ変数ポインタを使って label==& #34;foo& #34; の要素数を数える
991
- + int n1 = std::ranges::count(v, std::string(& #34;foo& #34;), & amp;Item::label);
992
- + std::cout & lt;& lt; & #34;count of label==\& #34;foo\& #34;: & #34; & lt;& lt; n1 & lt;& lt; std::endl;
993
- +
994
- + // ラムダ式を使って id==1 の要素数を数える
995
- + int n2 = std::ranges::count(v, 1, [](const Item& amp; p) { return p.id; });
996
- + std::cout & lt;& lt; & #34;count of id==1: & #34; & lt;& lt; n2 & lt;& lt; std::endl;
997
- +}
998
- +```
999
- +* std::ranges::count[color ff0000]
1000
- +
1001
- +#### 出力
1002
- +```
1003
- +count of label==& #34;foo& #34;: 2
1004
- +count of id==1: 2
1005
- +```
1006
- +
1007
-
1008
- ## 実装例
1009
- ```cpp
1010
- < /code>< /pre> </summary >
1011
-
1012
- <author >
1013
- <name >Akira Takahashi</name >
1014
-
1015
- </author >
1016
- </entry >
1017
-
1018
- <entry >
1019
- <title >equal_range -- ranges::count, equal_range, lower_bound : 射影変換の例を追加</title >
1020
- <link href =" https://cpprefjp.github.io/reference/algorithm/ranges_equal_range.html" />
1021
- <id >1f87d6a9e341dd8e5fe7a0f74d7545a804e9895a:reference/algorithm/ranges_equal_range.md</id >
1022
- <updated >2025-05-27T17:23:04+09:00</updated >
1023
-
1024
- <summary type =" html" >< pre>< code> diff --git a/reference/algorithm/ranges_equal_range.md b/reference/algorithm/ranges_equal_range.md
1025
- index 225f563da..fa5266fb4 100644
1026
- --- a/reference/algorithm/ranges_equal_range.md
1027
- +++ b/reference/algorithm/ranges_equal_range.md
1028
- @@ -182,6 +182,62 @@ int main() {
1029
- 3,4
1030
- ```
1031
-
1032
- +### 射影変換を使用した例
1033
- +```cpp example
1034
- +#include & lt;iostream& gt;
1035
- +#include & lt;vector& gt;
1036
- +#include & lt;algorithm& gt;
1037
- +#include & lt;string& gt;
1038
- +
1039
- +struct X {
1040
- + int id;
1041
- + std::string name;
1042
- +};
1043
- +
1044
- +int main() {
1045
- + std::vector& lt;X& gt; v = {
1046
- + {1, & #34;Carol& #34;},
1047
- + {3, & #34;Alice& #34;},
1048
- + {4, & #34;Bob& #34;},
1049
- + {4, & #34;Bob& #34;},
1050
- + {5, & #34;Eve& #34;},
1051
- + {6, & #34;Dave& #34;}
1052
- + };
1053
- + const std::string key = & #34;Bob& #34;;
1054
- +
1055
- + // メンバ変数nameをキーとして検索
1056
- + // 1. メンバ変数ポインタを使う方法
1057
- + auto result1 = std::ranges::equal_range(v, key, {}, & amp;X::name);
1058
- + std::cout & lt;& lt; & #34;[メンバ変数ポインタ]& #34; & lt;& lt; std::endl;
1059
- + for (const X& amp; x : result1) {
1060
- + std::cout & lt;& lt; & #34;id=& #34; & lt;& lt; x.id & lt;& lt; & #34; name=& #34; & lt;& lt; x.name & lt;& lt; std::endl;
1061
- + }
1062
- +
1063
- + // 2. ラムダ式を使う方法
1064
- + auto result2 = std::ranges::equal_range(
1065
- + v,
1066
- + key,
1067
- + {},
1068
- + [](const X& amp; x) { return x.name; }
1069
- +);
1070
- + std::cout & lt;& lt; & #34;[ラムダ式]& #34; & lt;& lt; std::endl;
1071
- + for (const X& amp; x : result2) {
1072
- + std::cout & lt;& lt; & #34;id=& #34; & lt;& lt; x.id & lt;& lt; & #34; name=& #34; & lt;& lt; x.name & lt;& lt; std::endl;
1073
- + }
1074
- +}
1075
- +```
1076
- +* std::ranges::equal_range[color ff0000]
1077
- +
1078
- +#### 出力
1079
- +```
1080
- +[メンバ変数ポインタ]
1081
- +id=4 name=Bob
1082
- +id=4 name=Bob
1083
- +[ラムダ式]
1084
- +id=4 name=Bob
1085
- +id=4 name=Bob
1086
- +```
1087
- +
1088
- ## バージョン
1089
- ### 言語
1090
- - C++20
1091
- < /code>< /pre> </summary >
1092
-
1093
- <author >
1094
- <name >Akira Takahashi</name >
1095
-
1096
- </author >
1097
- </entry >
1098
-
1099
- <entry >
1100
- <title >lower_bound -- ranges::count, equal_range, lower_bound : 射影変換の例を追加</title >
1101
- <link href =" https://cpprefjp.github.io/reference/algorithm/ranges_lower_bound.html" />
1102
- <id >1f87d6a9e341dd8e5fe7a0f74d7545a804e9895a:reference/algorithm/ranges_lower_bound.md</id >
1103
- <updated >2025-05-27T17:23:04+09:00</updated >
1104
-
1105
- <summary type =" html" >< pre>< code> diff --git a/reference/algorithm/ranges_lower_bound.md b/reference/algorithm/ranges_lower_bound.md
1106
- index 9fb2c5659..9b4d1be4f 100644
1107
- --- a/reference/algorithm/ranges_lower_bound.md
1108
- +++ b/reference/algorithm/ranges_lower_bound.md
1109
- @@ -230,6 +230,62 @@ int main() {
1110
- pos=2
1111
- ```
1112
-
1113
- +### 射影変換を使用した例
1114
- +```cpp example
1115
- +#include & lt;iostream& gt;
1116
- +#include & lt;algorithm& gt;
1117
- +#include & lt;vector& gt;
1118
- +#include & lt;string& gt;
1119
- +
1120
- +struct X {
1121
- + int id;
1122
- + std::string name;
1123
- +};
1124
- +
1125
- +int main() {
1126
- + std::vector& lt;X& gt; v = {
1127
- + {1, & #34;Carol& #34;},
1128
- + {3, & #34;Alice& #34;},
1129
- + {4, & #34;Bob& #34;},
1130
- + {5, & #34;Eve& #34;},
1131
- + {6, & #34;Dave& #34;}
1132
- + };
1133
- + const std::string key = & #34;Bob& #34;;
1134
- +
1135
- + // nameメンバ変数をキーとして検索
1136
- + // 1. メンバ変数ポインタを使う方法
1137
- + auto it1 = std::ranges::lower_bound(v, key, {}, & amp;X::name);
1138
- + if (it1 != v.end() & amp;& amp; it1-& gt;name == key) {
1139
- + std::size_t pos = std::ranges::distance(v.begin(), it1);
1140
- + std::cout & lt;& lt; & #34;id=& #34; & lt;& lt; it1-& gt;id
1141
- + & lt;& lt; & #34; name=& #34; & lt;& lt; it1-& gt;name
1142
- + & lt;& lt; & #34; pos=& #34; & lt;& lt; pos & lt;& lt; std::endl;
1143
- + }
1144
- +
1145
- + // 2. ラムダ式を使う方法
1146
- + auto it2 = std::ranges::lower_bound(
1147
- + v,
1148
- + key,
1149
- + {},
1150
- + [](const X& amp; x) { return x.name; }
1151
- + );
1152
- + if (it2 != v.end() & amp;& amp; it2-& gt;name == key) {
1153
- + std::size_t pos = std::ranges::distance(v.begin(), it2);
1154
- + std::cout & lt;& lt; & #34;id=& #34; & lt;& lt; it2-& gt;id
1155
- + & lt;& lt; & #34; name=& #34; & lt;& lt; it2-& gt;name
1156
- + & lt;& lt; & #34; pos=& #34; & lt;& lt; pos & lt;& lt; std::endl;
1157
- + }
1158
- +}
1159
- +```
1160
- +* std::ranges::lower_bound[color ff0000]
1161
- +* std::ranges::distance[link /reference/iterator/ranges_distance.md]
1162
- +
1163
- +#### 出力
1164
- +```
1165
- +id=4 name=Bob pos=2
1166
- +id=4 name=Bob pos=2
1167
- +```
1168
- +
1169
- ## バージョン
1170
- ### 言語
1171
- - C++20
1172
- < /code>< /pre> </summary >
1173
-
1174
- <author >
1175
- <name >Akira Takahashi</name >
1176
-
1177
- </author >
1178
- </entry >
1179
-
1180
1001
</feed >
0 commit comments