public inbox for libstdc++-cvs@sourceware.org help / color / mirror / Atom feed
From: Jonathan Wakely <redi@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r12-5180] libstdc++: Make pmr::memory_resource::allocate implicitly create objects Date: Thu, 11 Nov 2021 20:02:15 +0000 (GMT) [thread overview] Message-ID: <20211111200215.7B994385782C@sourceware.org> (raw) https://gcc.gnu.org/g:083fd73202fb7387c16b6c9beab9841939a62acb commit r12-5180-g083fd73202fb7387c16b6c9beab9841939a62acb Author: Jonathan Wakely <jwakely@redhat.com> Date: Wed Nov 10 16:59:29 2021 +0000 libstdc++: Make pmr::memory_resource::allocate implicitly create objects Calling the placement version of ::operator new "implicitly creates objects in the returned region of storage" as per [intro.object]. This allows the returned memory to be used as storage for implicit-lifetime types (including arrays) without additional action by the caller. This is required by the proposed resolution of LWG 3147. libstdc++-v3/ChangeLog: * include/std/memory_resource (memory_resource::allocate): Implicitly create objects in the returned storage. Diff: --- libstdc++-v3/include/std/memory_resource | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libstdc++-v3/include/std/memory_resource b/libstdc++-v3/include/std/memory_resource index 6bca0afa018..97d37f18512 100644 --- a/libstdc++-v3/include/std/memory_resource +++ b/libstdc++-v3/include/std/memory_resource @@ -33,6 +33,7 @@ #if __cplusplus >= 201703L +#include <new> #include <vector> // vector #include <cstddef> // size_t, max_align_t, byte #include <shared_mutex> // shared_mutex @@ -103,7 +104,7 @@ namespace pmr void* allocate(size_t __bytes, size_t __alignment = _S_max_align) __attribute__((__returns_nonnull__,__alloc_size__(2),__alloc_align__(3))) - { return do_allocate(__bytes, __alignment); } + { return ::operator new(__bytes, do_allocate(__bytes, __alignment)); } void deallocate(void* __p, size_t __bytes, size_t __alignment = _S_max_align)
reply other threads:[~2021-11-11 20:02 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20211111200215.7B994385782C@sourceware.org \ --to=redi@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ --cc=libstdc++-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).