From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2136) id 4490D3948A6C; Wed, 17 Jun 2020 19:01:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4490D3948A6C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1592420465; bh=skDlzqpXAIc2YmhgkiZ2elikZU0731bocYX/OcpHEbk=; h=From:To:Subject:Date:From; b=SJ6B/nXc7QWTj2OkpAZvubZ3xFlwsKBzWbD4szgzPuTRzz5MpekqtYY5Sdjev80/T WXawxXnhVlIkeQp8S16mo3MTO1xziDOIjNoIO6C7v6QEZIW/iQZ/EaqZnZZFQT6jnH zK5A7xRMjEkxIAa1rYhQcHylF2+EbA3XLfDcp3kI= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Aldy Hernandez To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc/devel/ranger] libstdc++: uninitialized_construct_using_allocator should use construct_at (LWG 3321) X-Act-Checkin: gcc X-Git-Author: Jonathan Wakely X-Git-Refname: refs/heads/devel/ranger X-Git-Oldrev: 020a03eec7054adb10396067fab69d0ace00aada X-Git-Newrev: 5f3641d0c430523d839298a6876f907523811485 Message-Id: <20200617190105.4490D3948A6C@sourceware.org> Date: Wed, 17 Jun 2020 19:01:05 +0000 (GMT) X-BeenThere: libstdc++-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Jun 2020 19:01:05 -0000 https://gcc.gnu.org/g:5f3641d0c430523d839298a6876f907523811485 commit 5f3641d0c430523d839298a6876f907523811485 Author: Jonathan Wakely Date: Wed Feb 19 12:14:54 2020 +0000 libstdc++: uninitialized_construct_using_allocator should use construct_at (LWG 3321) * include/std/memory (uninitialized_construct_using_allocator): Use std::construct_at (LWG 3321). Diff: --- libstdc++-v3/ChangeLog | 3 +++ libstdc++-v3/include/std/memory | 7 ++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index eb83c632adc..5408a89c7fb 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,5 +1,8 @@ 2020-02-19 Jonathan Wakely + * include/std/memory (uninitialized_construct_using_allocator): Use + std::construct_at (LWG 3321). + * include/std/memory_resource (polymorphic_allocator::allocate_bytes) (polymorphic_allocator::allocate_object) (polymorphic_allocator::new_object): Add nodiscard attribute (LWG3304). diff --git a/libstdc++-v3/include/std/memory b/libstdc++-v3/include/std/memory index 14aedb70dac..aaee6e42c1a 100644 --- a/libstdc++-v3/include/std/memory +++ b/libstdc++-v3/include/std/memory @@ -387,9 +387,10 @@ get_pointer_safety() noexcept { return pointer_safety::relaxed; } uninitialized_construct_using_allocator(_Tp* __p, const _Alloc& __a, _Args&&... __args) { - void* __vp = const_cast(static_cast(__p)); - return ::new(__vp) _Tp(std::make_obj_using_allocator<_Tp>(__a, - std::forward<_Args>(__args)...)); + return std::apply([&](auto&&... __xs) { + return std::construct_at(__p, std::forward(__xs)...); + }, std::uses_allocator_construction_args<_Tp>(__a, + std::forward<_Args>(__args)...)); } // @}