68
68
69
69
</ head >
70
70
< body >
71
- < header data-kunai-mdinfo ="{"meta": {"header": ["memory_resource"], "id-type": ["function template"], "namespace": ["std::pmr"], "class": ["polymorphic_allocator"], "cpp": ["cpp17", "cpp20deprecated"]}, "sources": [{"id": "15c857b0f08a6f1d15801e735e7cd78e891400c2", "source": "#include <iostream>\n#include <memory_resource>\n\nint main()\n{\n std::pmr::polymorphic_allocator<int> alloc{};\n\n //\u30e1\u30e2\u30ea\u306e\u78ba\u4fdd\n int* array = alloc.allocate(4);\n\n //\u8981\u7d20\u3092\u69cb\u7bc9\n for (int i = 0; i < 4; ++i) {\n alloc.construct(array + i, i);\n }\n\n for (int i = 0; i < 4; ++i) {\n std::cout << array[i] << std::endl;\n }\n\n //\u8981\u7d20\u3092\u7834\u68c4\n for (int i = 0; i < 4; ++i) {\n alloc.destroy(array + i);\n }\n\n //\u30e1\u30e2\u30ea\u306e\u89e3\u653e\n alloc.deallocate(array, 4);\n}\n"}], "page_id": ["reference", "memory_resource", "polymorphic_allocator", "destroy"]} ">
71
+ < header data-kunai-mdinfo ="{"meta": {"header": ["memory_resource"], "id-type": ["function template"], "namespace": ["std::pmr"], "class": ["polymorphic_allocator"], "cpp": ["cpp17"]}, "sources": [{"id": "15c857b0f08a6f1d15801e735e7cd78e891400c2", "source": "#include <iostream>\n#include <memory_resource>\n\nint main()\n{\n std::pmr::polymorphic_allocator<int> alloc{};\n\n //\u30e1\u30e2\u30ea\u306e\u78ba\u4fdd\n int* array = alloc.allocate(4);\n\n //\u8981\u7d20\u3092\u69cb\u7bc9\n for (int i = 0; i < 4; ++i) {\n alloc.construct(array + i, i);\n }\n\n for (int i = 0; i < 4; ++i) {\n std::cout << array[i] << std::endl;\n }\n\n //\u8981\u7d20\u3092\u7834\u68c4\n for (int i = 0; i < 4; ++i) {\n alloc.destroy(array + i);\n }\n\n //\u30e1\u30e2\u30ea\u306e\u89e3\u653e\n alloc.deallocate(array, 4);\n}\n"}], "page_id": ["reference", "memory_resource", "polymorphic_allocator", "destroy"]} ">
72
72
< nav class ="navbar navbar-default " role ="navigation ">
73
73
< div class ="container-fluid ">
74
74
< div class ="navbar-header ">
200
200
201
201
< p class ="text-right "> < small >
202
202
最終更新日時(UTC):
203
- < span itemprop ="datePublished " content ="2024-06-11T13:45:38 ">
204
- 2024年06月11日 13時45分38秒
203
+ < span itemprop ="datePublished " content ="2024-08-09T04:35:29 ">
204
+ 2024年08月09日 04時35分29秒
205
205
</ span >
206
206
< br />
207
207
< span itemprop ="author " itemscope itemtype ="http://schema.org/Person ">
224
224
< div class ="row ">
225
225
< div class ="col-sm-12 content-body ">
226
226
227
- < div class ="identifier-type "> function template</ div > < div class ="header "> <memory_resource></ div > < h1 itemprop ="name "> < span class ="namespace " title ="namespace std::pmr "> std::pmr::</ span > < span class ="class " title ="class polymorphic_allocator "> polymorphic_allocator::</ span > < span class ="token "> destroy</ span > < span class ="cpp cpp17 " title ="C++17で追加 "> (C++17)</ span > < span class =" cpp cpp20deprecated text-warning " title =" C++20で非推奨 " > (C++20で非推奨) </ span > < /h1 >
227
+ < div class ="identifier-type "> function template</ div > < div class ="header "> <memory_resource></ div > < h1 itemprop ="name "> < span class ="namespace " title ="namespace std::pmr "> std::pmr::</ span > < span class ="class " title ="class polymorphic_allocator "> polymorphic_allocator::</ span > < span class ="token "> destroy</ span > < span class ="cpp cpp17 " title ="C++17で追加 "> (C++17)</ span > </ h1 >
228
228
< div itemprop ="articleBody "> < p > < div class ="codehilite "> < pre > < span > </ span > < code > < span class ="k "> template</ span > < span class ="o "> <</ span > < span class ="k "> class</ span > < span class ="nc "> T</ span > < span class ="o "> ></ span >
229
229
< span class ="kt "> void</ span > < span class ="n "> destroy</ span > < span class ="p "> (</ span > < span class ="n "> T</ span > < span class ="o "> *</ span > < span class ="n "> p</ span > < span class ="p "> );</ span >
230
230
</ code > </ pre > </ div >
231
231
</ p >
232
- < p > この関数はC++20で非推奨となった。不要な機能ではあるが、代わりが必要であれば< code > < a href ="../../memory/allocator_traits/destroy.html "> allocator_traits<Alloc>::destroy()</ a > </ code > もしくは< code > < a href ="../../memory/destroy_at.html "> destroy_at()</ a > </ code > を使用すること。</ p >
233
232
< h2 > 概要</ h2 >
234
233
< p > 指定された領域にある< code > T</ code > のオブジェクトを破棄する。</ p >
235
234
< h2 > 引数</ h2 >
@@ -239,11 +238,6 @@ <h2>引数</h2>
239
238
< h2 > 効果</ h2 >
240
239
< p > あたかも< code > p->~T()</ code > を実行したように、< code > p</ code > の指す< code > T</ code > のオブジェクトを破棄する。</ p >
241
240
< p > メモリ領域の解放は行われないため、別に< code > < a href ="deallocate.html "> deallocate</ a > </ code > で行う必要がある。</ p >
242
- < h2 > 非推奨の詳細</ h2 >
243
- < p > < code > polymorphic_allocator</ code > も含めたアロケータはコンテナから利用される際に< code > allocator_traits</ code > を介して利用され、< code > allocator_traits</ code > の提供するデフォルト実装によってアロケータとしての多くの部分が補われる。</ p >
244
- < p > 本関数は、< code > < a href ="../../memory/allocator_traits/destroy.html "> allocator_traits<Alloc>::destroy()</ a > </ code > で提供されているデフォルト実装と完全に同一の実装となっており、追加の事を何もしていない。従って有用性は何もなく、非推奨とされた。</ p >
245
- < p > おそらく、< code > < a href ="construct.html "> construct()</ a > </ code > メンバ関数との対称性を意識して追加されていたものと思われる。なお、< code > construct()</ code > メンバ関数は< a href ="../../memory/uses_allocator.html "> uses-allocator 構築</ a > のために追加の仕事を担っており、こちらの関数には有用であるため非推奨とはされていない。</ p >
246
- < p > < code > allocator_traits</ code > を介して< code > polymorphic_allocator</ code > を使用する場合は本関数の有無を気にする必要はないが、もし本関数が必要となった場合は代わりに< code > < a href ="../../memory/destroy_at.html "> destroy_at()</ a > </ code > を利用できる。</ p >
247
241
< h2 > 例</ h2 >
248
242
< p > < div class ="yata " id ="15c857b0f08a6f1d15801e735e7cd78e891400c2 "> < div class ="codehilite "> < pre > < span > </ span > < code > < span class ="cp "> #include</ span > < span class ="cpf "> < a href ="../../iostream.html "> <iostream></ a > </ span > < span class ="cp "> </ span >
249
243
< span class ="cp "> #include</ span > < span class ="cpf "> < a href ="../../memory_resource.html "> <memory_resource></ a > </ span > < span class ="cp "> </ span >
@@ -306,6 +300,10 @@ <h2>参照</h2>
306
300
< li > < a href ="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4562.html#memory.resource.synop " target ="_blank "> Working Draft, C++ Extensions for Library Fundamentals, Version 2</ a > </ li >
307
301
< li > < a href ="https://developercommunity.visualstudio.com/content/problem/394908/destroy-missing-member-function-of-stdpmrpolymorph.html " target ="_blank "> destroy: Missing member function of std::pmr::polymorphic_allocator - Developer Community</ a > </ li >
308
302
< li > < a href ="https://cplusplus.github.io/LWG/issue3036 " target ="_blank "> LWG Issue 3036. < code > polymorphic_allocator::destroy</ code > is extraneous</ a > </ li >
303
+ < li > < a href ="https://open-std.org/jtc1/sc22/wg21/docs/papers/2024/p2875r4.pdf " target ="_blank "> P2875R4 Undeprecate < code > polymorphic_allocator::destroy</ code > for C++26</ a > < ul >
304
+ < li > この関数はC++20で一度非推奨となったが、C++26で非推奨が取り消された。ただし、< code > < a href ="../../memory/allocator_traits/destroy.html "> allocator_traits<Alloc>::destroy()</ a > </ code > 関数や< code > < a href ="../../memory/destroy_at.html "> destroy_at()</ a > </ code > 関数で同等のことができる</ li >
305
+ </ ul >
306
+ </ li >
309
307
</ ul > </ div >
310
308
311
309
</ div >
0 commit comments