Commit 020a03ee by Jonathan Wakely

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).
parent 15411a64
2020-02-19 Jonathan Wakely <jwakely@redhat.com> 2020-02-19 Jonathan Wakely <jwakely@redhat.com>
* 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 LWG 3379. "safe" in several library names is misleading
* include/bits/range_access.h (enable_safe_range): Rename to * include/bits/range_access.h (enable_safe_range): Rename to
enable_borrowed_range. enable_borrowed_range.
......
...@@ -178,7 +178,7 @@ namespace pmr ...@@ -178,7 +178,7 @@ namespace pmr
{ _M_resource->deallocate(__p, __n * sizeof(_Tp), alignof(_Tp)); } { _M_resource->deallocate(__p, __n * sizeof(_Tp), alignof(_Tp)); }
#if __cplusplus > 201703L #if __cplusplus > 201703L
void* [[nodiscard]] void*
allocate_bytes(size_t __nbytes, allocate_bytes(size_t __nbytes,
size_t __alignment = alignof(max_align_t)) size_t __alignment = alignof(max_align_t))
{ return _M_resource->allocate(__nbytes, __alignment); } { return _M_resource->allocate(__nbytes, __alignment); }
...@@ -189,7 +189,7 @@ namespace pmr ...@@ -189,7 +189,7 @@ namespace pmr
{ _M_resource->deallocate(__p, __nbytes, __alignment); } { _M_resource->deallocate(__p, __nbytes, __alignment); }
template<typename _Up> template<typename _Up>
_Up* [[nodiscard]] _Up*
allocate_object(size_t __n = 1) allocate_object(size_t __n = 1)
{ {
if ((__detail::__int_limits<size_t>::max() / sizeof(_Up)) < __n) if ((__detail::__int_limits<size_t>::max() / sizeof(_Up)) < __n)
...@@ -204,7 +204,7 @@ namespace pmr ...@@ -204,7 +204,7 @@ namespace pmr
{ deallocate_bytes(__p, __n * sizeof(_Up), alignof(_Up)); } { deallocate_bytes(__p, __n * sizeof(_Up), alignof(_Up)); }
template<typename _Up, typename... _CtorArgs> template<typename _Up, typename... _CtorArgs>
_Up* [[nodiscard]] _Up*
new_object(_CtorArgs&&... __ctor_args) new_object(_CtorArgs&&... __ctor_args)
{ {
_Up* __p = allocate_object<_Up>(); _Up* __p = allocate_object<_Up>();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment