std::allocator 是否处理 C++17 中的过度对齐类型?
Does std::allocator handle over-aligned types in C++17?
C++17 引入了 std::aligned_alloc
和对齐感知 new
可以进行过度对齐分配,但是 std::allocator
呢?它能处理过度对齐的类型吗?
在 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.
与C++14相比,句子
It is implementation-defined whether over-aligned types are supported
已删除。所以 std::allocator
应该支持 C++17 中的过度对齐类型。
C++17 引入了 std::aligned_alloc
和对齐感知 new
可以进行过度对齐分配,但是 std::allocator
呢?它能处理过度对齐的类型吗?
在 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.
与C++14相比,句子
It is implementation-defined whether over-aligned types are supported
已删除。所以 std::allocator
应该支持 C++17 中的过度对齐类型。