22<feed xmlns =" http://www.w3.org/2005/Atom" >
33 <title >cpprefjp - C++日本語リファレンス</title >
44 <link href =" https://cpprefjp.github.io" />
5- <updated >2025-05-27T15 :53:18.895250 </updated >
6- <id >ab180faa-fddf-40a7-a259-fed6253216d1 </id >
5+ <updated >2025-05-28T05 :53:12.456076 </updated >
6+ <id >2a530736-59f8-414a-b9d8-fdc077fcf0f8 </id >
77
88
9+ <entry >
10+ <title >projected -- projected : C++26での不完全型への対策に対応 (close #1185)</title >
11+ <link href =" https://cpprefjp.github.io/reference/iterator/projected.html" />
12+ <id >1fe3de6f2d3c0162a5f2b4b89231c01f20f24380:reference/iterator/projected.md</id >
13+ <updated >2025-05-28T14:49:37+09:00</updated >
14+
15+ <summary type =" html" >< pre>< code> diff --git a/reference/iterator/projected.md b/reference/iterator/projected.md
16+ index cf694bbc7..85023e7ad 100644
17+ --- a/reference/iterator/projected.md
18+ +++ b/reference/iterator/projected.md
19+ @@ -6,20 +6,30 @@
20+
21+ ```cpp
22+ namespace std {
23+ -
24+ - template& lt;indirectly_readable I, indirectly_regular_unary_invocable& lt;I& gt; Proj& gt;
25+ + // (1) C++20の定義
26+ + template & lt;indirectly_readable I, indirectly_regular_unary_invocable& lt;I& gt; Proj& gt;
27+ struct projected {
28+ using value_type = remove_cvref_t& lt;indirect_result_t& lt;Proj& amp;, I& gt;& gt;;
29+
30+ indirect_result_t& lt;Proj& amp;, I& gt; operator*() const; // 宣言のみ
31+ };
32+ -
33+ -
34+ // incrementable_traitsにアダプトする
35+ - template& lt;weakly_incrementable I, class Proj& gt;
36+ + template & lt;weakly_incrementable I, class Proj& gt;
37+ struct incrementable_traits& lt;projected& lt;I, Proj& gt;& gt; {
38+ using difference_type = iter_difference_t& lt;I& gt;;
39+ };
40+ +
41+ + // (1) C++26の定義
42+ + template & lt;class I, class Proj& gt;
43+ + struct projected-impl { // 説明用の型
44+ + struct type { // 説明用の型
45+ + using value_type = remove_cvref_t& lt;indirect_result_t& lt;Proj& amp;, I& gt;& gt;;
46+ + using difference_type = iter_difference_t& lt;I& gt;; // weakly_incrementableをモデル化する場合にのみ存在する
47+ + indirect_result_t& lt;Proj& amp;, I& gt; operator*() const; // 宣言のみで定義なし
48+ + };
49+ + };
50+ + template & lt;indirectly_readable I, indirectly_regular_unary_invocable& lt;I& gt; Proj& gt;
51+ + using projected = projected-impl& lt;I, Proj& gt;::type;
52+ }
53+ ```
54+ * indirectly_readable[link /reference/iterator/indirectly_readable.md]
55+ @@ -34,6 +44,15 @@ namespace std {
56+
57+ これは射影操作を受け取るコンセプトやアルゴリズムを制約するために使用するものであり、評価される文脈で使用可能ではない。主に、射影操作の結果に対してイテレータ関連のコンセプトを適用する場合に使用する(射影の結果を再び`indirectly_readable`な型に写す事で、一部のイテレータに対するコンセプトを使いまわす事が出来る)。
58+
59+ +
60+ +## 備考
61+ +- C++26:
62+ + - C++20の`projected`の定義では、ADLによって不完全型に完全な定義を要求してしまっており、以下のようなコードがコンパイルエラーになっていたが、C++26での定義変更によって不完全型が許容されるようになった。
63+ + ```cpp
64+ + Holder& lt;Incomplete& gt; *a[10] = {};
65+ + std::ranges::count(a, a + 10, nullptr); // コンパイルエラー
66+ + ```
67+ +
68+ ## 例
69+ ```cpp example
70+ #include & lt;iterator& gt;
71+ @@ -95,3 +114,4 @@ int main() {
72+ ## 参照
73+
74+ - [P0896R4 The One Ranges Proposal (was Merging the Ranges TS)](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0896r4.pdf)
75+ +- [P2538R1 ADL-proof `std::projected`](http://open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2538r1.html)
76+ < /code>< /pre> </summary >
77+
78+ <author >
79+ <name >Akira Takahashi</name >
80+ 81+ </author >
82+ </entry >
83+
984 <entry >
1085 <title >execution -- execution: bulk (#1384)</title >
1186 <link href =" https://cpprefjp.github.io/reference/execution/execution.html" />
@@ -1102,85 +1177,4 @@ index 9fb2c5659..9b4d1be4f 100644
11021177 </author >
11031178 </entry >
11041179
1105- <entry >
1106- <title >find -- ranges::find : 射影変換の例を追加</title >
1107- <link href =" https://cpprefjp.github.io/reference/algorithm/ranges_find.html" />
1108- <id >0dfcb84d27bb4a6a4eed9c75a13522415335c80a:reference/algorithm/ranges_find.md</id >
1109- <updated >2025-05-27T17:08:10+09:00</updated >
1110-
1111- <summary type =" html" >< pre>< code> diff --git a/reference/algorithm/ranges_find.md b/reference/algorithm/ranges_find.md
1112- index 7f76d5976..41dfe9d96 100644
1113- --- a/reference/algorithm/ranges_find.md
1114- +++ b/reference/algorithm/ranges_find.md
1115- @@ -102,6 +102,62 @@ int main() {
1116- found: 1
1117- ```
1118-
1119- +### 射影変換を使用した例
1120- +```cpp example
1121- +#include & lt;algorithm& gt;
1122- +#include & lt;iostream& gt;
1123- +#include & lt;vector& gt;
1124- +#include & lt;string& gt;
1125- +
1126- +struct Item {
1127- + int id;
1128- + std::string name;
1129- +};
1130- +
1131- +int main() {
1132- + std::vector& lt;Item& gt; v = {
1133- + {1, & #34;aaa& #34;},
1134- + {3, & #34;bbb& #34;},
1135- + {5, & #34;ccc& #34;}
1136- + };
1137- +
1138- + // メンバ変数ポインタを使って特定のメンバ変数で検索
1139- + {
1140- + auto it = std::ranges::find(
1141- + v,
1142- + std::string(& #34;bbb& #34;),
1143- + & amp;Item::name
1144- + );
1145- + if (it == v.end()) {
1146- + std::cout & lt;& lt; & #34;not found& #34; & lt;& lt; std::endl;
1147- + } else {
1148- + std::cout & lt;& lt; & #34;found: & #34; & lt;& lt; it-& gt;id & lt;& lt; & #39;,& #39; & lt;& lt; it-& gt;name & lt;& lt; std::endl;
1149- + }
1150- + }
1151- +
1152- + // ラムダ式で特定のメンバ変数を検索
1153- + {
1154- + auto it = std::ranges::find(
1155- + v,
1156- + std::string(& #34;bbb& #34;),
1157- + [](const Item& amp; x) { return x.name; }
1158- + );
1159- + if (it == v.end()) {
1160- + std::cout & lt;& lt; & #34;not found& #34; & lt;& lt; std::endl;
1161- + } else {
1162- + std::cout & lt;& lt; & #34;found: & #34; & lt;& lt; it-& gt;id & lt;& lt; & #39;,& #39; & lt;& lt; it-& gt;name & lt;& lt; std::endl;
1163- + }
1164- + }
1165- +}
1166- +```
1167- +* std::ranges::find[color ff0000]
1168- +
1169- +#### 出力
1170- +```
1171- +found: 3,bbb
1172- +found: 3,bbb
1173- +```
1174- +
1175- ### 波カッコ初期化を入力として使用する (C++26)
1176- ```cpp example
1177- #include & lt;algorithm& gt;
1178- < /code>< /pre> </summary >
1179-
1180- <author >
1181- <name >Akira Takahashi</name >
1182- 1183- </author >
1184- </entry >
1185-
11861180</feed >
0 commit comments