|
68 | 68 |
|
69 | 69 | </head> |
70 | 70 | <body> |
71 | | -<header data-kunai-mdinfo="{"meta": {"header": ["functional"], "id-type": ["class template"], "namespace": ["std"], "cpp": ["cpp26"]}, "sources": [{"id": "a4d509b525a590392232c6da5bc08abd7916c96f", "source": "#include <functional>\n#include <iostream>\n#include <utility>\n\n// \u547c\u3073\u51fa\u3057\u53ef\u80fd\u306a\u4f55\u304b\u3092\u53d7\u3051\u53d6\u308b\u9ad8\u968e\u95a2\u6570\nint hof(std::function_ref<int(int)> fn)\n{\n return fn(2);\n}\n\nint add(int x) { return x + 1; }\n\nstruct Calc {\n int x_;\n int eval(int y) {\n return x_ * y;\n }\n};\n\nint main()\n{\n // \u901a\u5e38\u95a2\u6570\u3092\u6307\u5b9a\n std::cout << hof(add) << std::endl;\n // \u30e9\u30e0\u30c0\u5f0f\u3092\u6307\u5b9a\n std::cout << hof([](int x) { return x * 2; }) << std::endl;\n\n // \u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u675f\u7e1b\u6e08\u307f\u30e1\u30f3\u30d0\u95a2\u6570\u3092\u6307\u5b9a\n Calc obj{ 3 };\n std::cout << hof({std::nontype<&Calc::eval>, obj}) << std::endl;\n}\n"}], "page_id": ["reference", "functional", "function_ref"]}"> |
| 71 | +<header data-kunai-mdinfo="{"meta": {"header": ["functional"], "id-type": ["class template"], "namespace": ["std"], "cpp": ["cpp26"]}, "sources": [{"id": "0d41b69c637c34821fffc357d27125b85fe12550", "source": "#include <functional>\n#include <iostream>\n#include <utility>\n\n// \u547c\u3073\u51fa\u3057\u53ef\u80fd\u306a\u4f55\u304b\u3092\u53d7\u3051\u53d6\u308b\u9ad8\u968e\u95a2\u6570\nint hof(std::function_ref<int(int)> fn)\n{\n return fn(2);\n}\n\nint add(int x) { return x + 1; }\n\nstruct Calc {\n int x_;\n int eval(int y) {\n return x_ * y;\n }\n};\n\nint main()\n{\n // \u901a\u5e38\u95a2\u6570\u3092\u6307\u5b9a\n std::cout << hof(add) << std::endl;\n // \u30e9\u30e0\u30c0\u5f0f\u3092\u6307\u5b9a\n std::cout << hof([](int x) { return x * 2; }) << std::endl;\n\n // \u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u675f\u7e1b\u6e08\u307f\u30e1\u30f3\u30d0\u95a2\u6570\u3092\u6307\u5b9a\n Calc obj{ 3 };\n std::cout << hof({std::constant_arg<&Calc::eval>, obj}) << std::endl;\n}\n"}], "page_id": ["reference", "functional", "function_ref"]}"> |
72 | 72 | <nav class="navbar navbar-default" role="navigation"> |
73 | 73 | <div class="container-fluid"> |
74 | 74 | <div class="navbar-header"> |
|
188 | 188 |
|
189 | 189 | <p class="text-right"><small> |
190 | 190 | 最終更新日時(UTC): |
191 | | - <span itemprop="datePublished" content="2024-01-07T03:21:49"> |
192 | | - 2024年01月07日 03時21分49秒 |
| 191 | + <span itemprop="datePublished" content="2026-02-11T06:05:02"> |
| 192 | + 2026年02月11日 06時05分02秒 |
193 | 193 | </span> |
194 | 194 | <br/> |
195 | 195 | <span itemprop="author" itemscope itemtype="http://schema.org/Person"> |
@@ -242,7 +242,7 @@ <h3><code>function</code>ファミリとの比較</h3> |
242 | 242 | <li><code>operator bool</code>を提供しない。</li> |
243 | 243 | </ul> |
244 | 244 | </li> |
245 | | -<li>メンバ関数・メンバ変数を参照する場合は、<code><a href="../utility/nontype_t.html">std::nontype</a></code>タグを利用する。<ul> |
| 245 | +<li>メンバ関数・メンバ変数を参照する場合は、<code><a href="../utility/constant_arg_t.html">std::constant_arg</a></code>タグを利用する。<ul> |
246 | 246 | <li>対象オブジェクトの束縛タイミングは、構築時または呼び出し時のいずれもサポートする。</li> |
247 | 247 | </ul> |
248 | 248 | </li> |
@@ -299,7 +299,7 @@ <h2>推論補助</h2> |
299 | 299 | </table> |
300 | 300 | <h2>例</h2> |
301 | 301 | <h3>例1: 基本の使い方</h3> |
302 | | -<p><div class="yata" id="a4d509b525a590392232c6da5bc08abd7916c96f"><div class="codehilite"><pre><span></span><code><span class="cp">#include</span> <span class="cpf"><a href="../functional.html"><functional></a></span><span class="cp"></span> |
| 302 | +<p><div class="yata" id="0d41b69c637c34821fffc357d27125b85fe12550"><div class="codehilite"><pre><span></span><code><span class="cp">#include</span> <span class="cpf"><a href="../functional.html"><functional></a></span><span class="cp"></span> |
303 | 303 | <span class="cp">#include</span> <span class="cpf"><a href="../iostream.html"><iostream></a></span><span class="cp"></span> |
304 | 304 | <span class="cp">#include</span> <span class="cpf"><a href="../utility.html"><utility></a></span><span class="cp"></span> |
305 | 305 |
|
@@ -327,7 +327,7 @@ <h3>例1: 基本の使い方</h3> |
327 | 327 |
|
328 | 328 | <span class="c1">// オブジェクト束縛済みメンバ関数を指定</span> |
329 | 329 | <span class="n">Calc</span> <span class="n">obj</span><span class="p">{</span> <span class="mi">3</span> <span class="p">};</span> |
330 | | - <span class="n"><a href="../iostream/cout.html">std::cout</a></span> <span class="o"><<</span> <span class="n">hof</span><span class="p">({</span><span class="n"><a href="../utility/nontype_t.html">std::nontype</a></span><span class="o"><&</span><span class="n">Calc</span><span class="o">::</span><span class="n">eval</span><span class="o">></span><span class="p">,</span> <span class="n">obj</span><span class="p">})</span> <span class="o"><<</span> <span class="n"><a href="../ostream/endl.html">std::endl</a></span><span class="p">;</span> |
| 330 | + <span class="n"><a href="../iostream/cout.html">std::cout</a></span> <span class="o"><<</span> <span class="n">hof</span><span class="p">({</span><span class="n"><a href="../utility/constant_arg_t.html">std::constant_arg</a></span><span class="o"><&</span><span class="n">Calc</span><span class="o">::</span><span class="n">eval</span><span class="o">></span><span class="p">,</span> <span class="n">obj</span><span class="p">})</span> <span class="o"><<</span> <span class="n"><a href="../ostream/endl.html">std::endl</a></span><span class="p">;</span> |
331 | 331 | <span class="p">}</span> |
332 | 332 | </code></pre></div> |
333 | 333 | </div></p> |
@@ -357,6 +357,7 @@ <h2>関連項目</h2> |
357 | 357 | <h2>参照</h2> |
358 | 358 | <ul> |
359 | 359 | <li><a href="https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/p0792r14.html" target="_blank">P0792R14 <code>function_ref</code>: a type-erased callable reference</a></li> |
| 360 | +<li><a href="https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p3774r1.html" target="_blank">P3774R1 Rename <code>std::nontype</code>, and make it broadly useful</a></li> |
360 | 361 | </ul></div> |
361 | 362 |
|
362 | 363 | </div> |
|
0 commit comments