C++17 introduces std::aligned_alloc and alignment-aware new that can do over-aligned allocations, but what about std::allocator? Does it handle over-aligned types?
- oops, I deleted my wrong answer , a copy-paste horror story ... ( feel free to down vote me ... :) )Massimiliano Janes– Massimiliano Janes2017-09-25 07:56:31 +00:00Commented Sep 25, 2017 at 7:56
- 1Yes, open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0035r4.html removed the text making it implementation defined.Marc Glisse– Marc Glisse2017-09-25 08:01:27 +00:00Commented Sep 25, 2017 at 8:01
- @MassimilianoJanes Never mind, I've found the section in N4659(C++17 DIS).Jamboree– Jamboree2017-09-25 08:03:05 +00:00Commented Sep 25, 2017 at 8:03
Add a comment |
1 Answer
In N4659(C++17 DIS), 23.10.9.1 [allocator.members], bullet 2
T* allocate(size_t n);
Returns: A pointer to the initial element of an array of storage of size n * sizeof(T), aligned appropriately for objects of type T.
Compared to C++14, the sentence
It is implementation-defined whether over-aligned types are supported
has been removed. So std::allocator should support over-aligned types in C++17.
5 Comments
Massimiliano Janes
uhm, N4659 ( the pdf version I found at www.open-std.org ) still reads verbatim as per my original answer, that is that overaligned types support is implementation defined ...
Jamboree
@MassimilianoJanes I found it at github.com/timsong-cpp/cppwp, not sure the one at www.open-std.org.
Massimiliano Janes
ok reading Marc Glisse's comment is clear you're right ( good to know that the allocation functions takes also an alignment parameter now ).
sandthorn
Could you click accept this answer? This is very why aligned_allocator is not longer neccessary.
KeyC0de
@Jamboree This is great. Thanks for digging this up.