Created on 2019-11-04.00:00:00 last changed 61 months ago
Proposed resolution:
This wording is relative to N4835.
Modify [mem.poly.allocator.class] p2, class template polymorphic_allocator synopsis, as indicated:
// [mem.poly.allocator.mem], member functions
[[nodiscard]] Tp* allocate(size_t n);
void deallocate(Tp* p, size_t n);
void* allocate_bytes(size_t nbytes, size_t alignment = alignof(max_align_t));
void deallocate_bytes(void* p, size_t nbytes, size_t alignment = alignof(max_align_t));
template<class T> [[nodiscard]] T* allocate_object(size_t n = 1);
template<class T> void deallocate_object(T* p, size_t n = 1);
template<class T, class... CtorArgs> [[nodiscard]] T* new_object(CtorArgs&&... ctor_args);
template<class T> void delete_object(T* p);
Modify [mem.poly.allocator.mem] as indicated:
template<class T> [[nodiscard]] T* allocate_object(size_t n = 1);-8- Effects: Allocates memory suitable for holding an array of n objects of type T, as follows:
[…]
(8.1) — if SIZE_MAX / sizeof(T) < n, throws length_error,
(8.2) — otherwise equivalent to:
return static_cast<T*>(allocate_bytes(n*sizeof(T), alignof(T)));template<class T, class CtorArgs...> [[nodiscard]] T* new_object(CtorArgs&&... ctor_args);-11- Effects: Allocates and constructs an object of type T, as follows. Equivalent to:
[…]T* p = allocate_object<T>(); try { construct(p, std::forward<CtorArgs>(ctor_args)...); } catch (...) { deallocate_object(p); throw; } return p;
[ 2019-11 Status to Duplicate during Tuesday morning issue processing in Belfast. ]
Duplicate of 3304.
[ Daniel comments ]
This issue is related to LWG 3304.
Addresses US 217
Add [[nodiscard]] in front of the return type for allocate_object and new_object in class declaration and in member-function description for polymorphic_allocator template.
History | |||
---|---|---|---|
Date | User | Action | Args |
2019-11-07 08:20:25 | admin | set | messages: + msg10785 |
2019-11-07 08:20:25 | admin | set | status: new -> dup |
2019-11-04 19:27:15 | admin | set | messages: + msg10738 |
2019-11-04 19:27:15 | admin | set | messages: + msg10737 |
2019-11-04 00:00:00 | admin | create |