From 020a03eec7054adb10396067fab69d0ace00aada Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Wed, 19 Feb 2020 12:04:53 +0000 Subject: [PATCH] libstdc++: Add nodiscard to polymorphic_allocator members (LWG 3304) * include/std/memory_resource (polymorphic_allocator::allocate_bytes) (polymorphic_allocator::allocate_object) (polymorphic_allocator::new_object): Add nodiscard attribute (LWG3304). --- libstdc++-v3/ChangeLog | 4 ++++ libstdc++-v3/include/std/memory_resource | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 045f0badfae..eb83c632adc 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,5 +1,9 @@ 2020-02-19 Jonathan Wakely + * include/std/memory_resource (polymorphic_allocator::allocate_bytes) + (polymorphic_allocator::allocate_object) + (polymorphic_allocator::new_object): Add nodiscard attribute (LWG3304). + LWG 3379. "safe" in several library names is misleading * include/bits/range_access.h (enable_safe_range): Rename to enable_borrowed_range. diff --git a/libstdc++-v3/include/std/memory_resource b/libstdc++-v3/include/std/memory_resource index 70c56d1d7e6..73f77bdcadf 100644 --- a/libstdc++-v3/include/std/memory_resource +++ b/libstdc++-v3/include/std/memory_resource @@ -178,7 +178,7 @@ namespace pmr { _M_resource->deallocate(__p, __n * sizeof(_Tp), alignof(_Tp)); } #if __cplusplus > 201703L - void* + [[nodiscard]] void* allocate_bytes(size_t __nbytes, size_t __alignment = alignof(max_align_t)) { return _M_resource->allocate(__nbytes, __alignment); } @@ -189,7 +189,7 @@ namespace pmr { _M_resource->deallocate(__p, __nbytes, __alignment); } template - _Up* + [[nodiscard]] _Up* allocate_object(size_t __n = 1) { if ((__detail::__int_limits::max() / sizeof(_Up)) < __n) @@ -204,7 +204,7 @@ namespace pmr { deallocate_bytes(__p, __n * sizeof(_Up), alignof(_Up)); } template - _Up* + [[nodiscard]] _Up* new_object(_CtorArgs&&... __ctor_args) { _Up* __p = allocate_object<_Up>(); -- 2.30.2