Skip to content

Commit e8c4281

Browse files
author
cpprefjp-autoupdate
committed
update automatically
1 parent 3c9f004 commit e8c4281

File tree

3 files changed

+41
-94
lines changed

3 files changed

+41
-94
lines changed

lang/cpp20/more_constexpr_containers.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,12 +188,12 @@
188188

189189
<p class="text-right"><small>
190190
最終更新日時(UTC):
191-
<span itemprop="datePublished" content="2024-07-08T07:33:21">
192-
2024年07月08日 07時33分21秒
191+
<span itemprop="datePublished" content="2025-01-09T11:51:24">
192+
2025年01月09日 11時51分24秒
193193
</span>
194194
<br/>
195195
<span itemprop="author" itemscope itemtype="http://schema.org/Person">
196-
<span itemprop="name">Akira Takahashi</span>
196+
<span itemprop="name">Yuhki Ogasawara</span>
197197
</span>
198198
が更新
199199
</small></p>
@@ -426,7 +426,7 @@ <h3><code>std::allocator/std::allocator_traits</code></h3>
426426
<p><code>std::allocator::allocate()</code>はグローバルの<code>::operator new()</code>を呼び出すが、この呼び出しは<code>new</code>式の時と同様に省略されており、<code>std::allocator::deallocate()</code>における<code>::operator delete()</code>の呼び出しも省略されている。この2つもまた<code>new/delete</code>式と同様に、メモリの確保と解放が一貫していることのマーカーとしての側面が強くなっている。</p>
427427
<p>結局、C++20のコンパイル時動的メモリ確保は定数式にヒープ領域を導入するものではなく、デフォルトの<code>::operator new</code>による動的メモリ確保を別の領域をあてがう形に置換することで行われている。</p>
428428
<h2>この機能が必要になった背景・経緯</h2>
429-
<p><code>std::vector</code>をはじめとする可変サイズのコンテナは実行時に非常に有用であるため、同様に定数式においても有用である可能性があり、その必要性がC++コミュニティからも示されいていた<a href="https://youtu.be/HMB9oXFobJc" target="_blank">C++Now 2017: Ben Deane &amp; Jason Turner "constexpr ALL the things!"</a><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0810r0.pdf" target="_blank">P0810R0 constexpr in Practice</a>など)。</p>
429+
<p><code>std::vector</code>をはじめとする可変サイズのコンテナは実行時に非常に有用であるため、同様に定数式においても有用である可能性があり、その必要性がC++コミュニティからも示されていた<a href="https://youtu.be/HMB9oXFobJc" target="_blank">C++Now 2017: Ben Deane &amp; Jason Turner "constexpr ALL the things!"</a><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0810r0.pdf" target="_blank">P0810R0 constexpr in Practice</a>など)。</p>
430430
<p>また、静的リフレクション機能の導入にあたっては、コンパイル時に使用可能な可変サイズコンテナおよび可変サイズの文字列型が必要となっていた。例えば、ある型のテンプレート引数をクエリするコードは次のようなものになる</p>
431431
<p><div class="codehilite"><pre><span></span><code><span class="c1">// 型Tのテンプレート引数の情報を取り出す</span>
432432
<span class="n"><a href="../../reference/vector/vector.html">std::vector</a></span><span class="o">&lt;</span><span class="n">std</span><span class="o">::</span><span class="n">metainfo</span><span class="o">&gt;</span> <span class="n">args</span> <span class="o">=</span> <span class="n">std</span><span class="o">::</span><span class="n">meta</span><span class="o">::</span><span class="n">get_template_args</span><span class="p">(</span><span class="n">reflexpr</span><span class="p">(</span><span class="n">T</span><span class="p">));</span>

rss.xml

Lines changed: 36 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,44 @@
22
<feed xmlns="http://www.w3.org/2005/Atom">
33
<title>cpprefjp - C++日本語リファレンス</title>
44
<link href="https://cpprefjp.github.io" />
5-
<updated>2025-01-08T14:41:29.003356</updated>
6-
<id>48180592-18ef-4c76-89aa-2e34b17199db</id>
5+
<updated>2025-01-09T11:54:26.633587</updated>
6+
<id>d4a27ec7-ebe4-41ae-b9cc-fc54789d5c9d</id>
77

88

9+
<entry>
10+
<title>可変サイズをもつコンテナのconstexpr化 [P0784R7] -- タイポの修正</title>
11+
<link href="https://cpprefjp.github.io/lang/cpp20/more_constexpr_containers.html"/>
12+
<id>b84a2272d7ee6558d4555cc247434dff541bd4a4:lang/cpp20/more_constexpr_containers.md</id>
13+
<updated>2025-01-09T20:51:24+09:00</updated>
14+
15+
<summary type="html">&lt;pre&gt;&lt;code&gt;diff --git a/lang/cpp20/more_constexpr_containers.md b/lang/cpp20/more_constexpr_containers.md
16+
index d6eb1a19e..a693e3c5b 100644
17+
--- a/lang/cpp20/more_constexpr_containers.md
18+
+++ b/lang/cpp20/more_constexpr_containers.md
19+
@@ -260,7 +260,7 @@ constexpr int g() {
20+
21+
## この機能が必要になった背景・経緯
22+
23+
-`std::vector`をはじめとする可変サイズのコンテナは実行時に非常に有用であるため、同様に定数式においても有用である可能性があり、その必要性がC++コミュニティからも示されいていた([C++Now 2017: Ben Deane &amp;amp; Jason Turner &amp;#34;constexpr ALL the things!&amp;#34;](https://youtu.be/HMB9oXFobJc)、[P0810R0 constexpr in Practice](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0810r0.pdf)など)。
24+
+`std::vector`をはじめとする可変サイズのコンテナは実行時に非常に有用であるため、同様に定数式においても有用である可能性があり、その必要性がC++コミュニティからも示されていた([C++Now 2017: Ben Deane &amp;amp; Jason Turner &amp;#34;constexpr ALL the things!&amp;#34;](https://youtu.be/HMB9oXFobJc)、[P0810R0 constexpr in Practice](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0810r0.pdf)など)。
25+
26+
また、静的リフレクション機能の導入にあたっては、コンパイル時に使用可能な可変サイズコンテナおよび可変サイズの文字列型が必要となっていた。例えば、ある型のテンプレート引数をクエリするコードは次のようなものになる
27+
28+
@@ -356,4 +356,4 @@ int main() {
29+
- [P0784R7 More constexpr containers](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p0784r7.html)
30+
- [動的メモリー確保 - 江添亮の入門C++](https://ezoeryou.github.io/cpp-intro/#動的メモリー確保)
31+
- [N3664 Clarifying Memory Allocation](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3664.html)
32+
-- [P1974R0 Non-transient constexpr allocation using propconst](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p1974r0.pdf)
33+
\ No newline at end of file
34+
+- [P1974R0 Non-transient constexpr allocation using propconst](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p1974r0.pdf)
35+
&lt;/code&gt;&lt;/pre&gt;</summary>
36+
37+
<author>
38+
<name>Yuhki Ogasawara</name>
39+
<email>[email protected]</email>
40+
</author>
41+
</entry>
42+
943
<entry>
1044
<title>svリテラル -- Merge pull request #1400 from cpprefjp/improve_op_sv</title>
1145
<link href="https://cpprefjp.github.io/reference/string_view/basic_string_view/op_sv.html"/>
@@ -259,91 +293,4 @@ index 2f079ffd8..a2cc2921f 100644
259293
</author>
260294
</entry>
261295

262-
<entry>
263-
<title>wait_for -- add example to see difference between `wait_for(0s) == ready` and `valid()`</title>
264-
<link href="https://cpprefjp.github.io/reference/future/future/wait_for.html"/>
265-
<id>2a7c46fa2a18a023bf05a8ed95830bd85a4b46da:reference/future/future/wait_for.md</id>
266-
<updated>2025-01-04T09:11:44+09:00</updated>
267-
268-
<summary type="html">&lt;pre&gt;&lt;code&gt;diff --git a/reference/future/future/wait_for.md b/reference/future/future/wait_for.md
269-
index fd77159de..2f079ffd8 100644
270-
--- a/reference/future/future/wait_for.md
271-
+++ b/reference/future/future/wait_for.md
272-
@@ -30,6 +30,7 @@ future_status wait_for(const chrono::duration&amp;lt;Rep, Period&amp;gt;&amp;amp; rel_time) const;
273-
274-
275-
## 例
276-
+### 例1
277-
```cpp example
278-
#include &amp;lt;iostream&amp;gt;
279-
#include &amp;lt;future&amp;gt;
280-
@@ -70,11 +71,59 @@ int main()
281-
* std::future_status[link /reference/future/future_status.md]
282-
* f.get()[link /reference/future/shared_future/get.md]
283-
284-
-### 出力例
285-
+#### 出力例
286-
```
287-
3
288-
```
289-
290-
+### 例2
291-
+```cpp example
292-
+#include &amp;lt;iostream&amp;gt;
293-
+#include &amp;lt;future&amp;gt;
294-
+#include &amp;lt;chrono&amp;gt;
295-
+
296-
+int main()
297-
+{
298-
+ std::promise&amp;lt;int&amp;gt; p;
299-
+ std::future&amp;lt;int&amp;gt; f = p.get_future();
300-
+ const auto ready = [&amp;amp;f] {
301-
+ return f.wait_for(std::chrono::seconds{0}) == std::future_status::ready;
302-
+ };
303-
+
304-
+ // まだ値はセットされていない
305-
+ std::cout &amp;lt;&amp;lt; std::boolalpha &amp;lt;&amp;lt; ready() &amp;lt;&amp;lt; std::endl;
306-
+
307-
+ p.set_value(1);
308-
+
309-
+ // 値がセットされた
310-
+ std::cout &amp;lt;&amp;lt; std::boolalpha &amp;lt;&amp;lt; ready() &amp;lt;&amp;lt; std::endl;
311-
+
312-
+ f.get(); // 一度値を取り出すと共有状態が破棄される
313-
+
314-
+ // 共有状態を持たない(valid() == falseな)futureでwaitをするとstd::future_error例外
315-
+ try {
316-
+ ready();
317-
+ }
318-
+ catch(const std::future_error&amp;amp; e) {
319-
+ std::cout &amp;lt;&amp;lt; e.what() &amp;lt;&amp;lt; std::endl;
320-
+ }
321-
+}
322-
+```
323-
+* wait_for[color ff0000]
324-
+* std::promise[link /reference/future/promise.md]
325-
+* p.set_value[link /reference/future/promise/set_value.md]
326-
+* std::future_status[link /reference/future/future_status.md]
327-
+* f.get()[link /reference/future/shared_future/get.md]
328-
+* valid()[link /reference/future/future/valid.md]
329-
+* std::future_error[link /reference/future/future_error.md]
330-
+
331-
+#### 出力例
332-
+```
333-
+false
334-
+true
335-
+std::future_error: No associated state
336-
+```
337-
+
338-
## バージョン
339-
### 言語
340-
- C++11
341-
&lt;/code&gt;&lt;/pre&gt;</summary>
342-
343-
<author>
344-
<name>I</name>
345-
<email>[email protected]</email>
346-
</author>
347-
</entry>
348-
349296
</feed>

sitemap.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35577,7 +35577,7 @@
3557735577

3557835578
<url>
3557935579
<loc>https://cpprefjp.github.io/lang/cpp20/more_constexpr_containers.html</loc>
35580-
<lastmod>2024-12-16T10:43:31+09:00</lastmod>
35580+
<lastmod>2025-01-09T20:51:24+09:00</lastmod>
3558135581
<changefreq>daily</changefreq>
3558235582
<priority>0.7</priority>
3558335583
</url>

0 commit comments

Comments
 (0)