C++ 17引入了std::aligned_alloc
和对齐感知的new
,它们可以执行over-aligned分配,但std::allocator
呢?它处理的是过度对齐的类型吗?std :: allocator是否处理C++ 17中的over-aligned类型?
回答
在N4659(C++ 17 DIS),23.10.9.1 [allocator.members], bullet 2
T *分配(为size_t N);
返回:指向大小为n * sizeof(T)的存储阵列的初始元素的指针,适用于T类型的对象。
相比C++ 14,句子
它实现定义
已被去除过对齐的类型是否被支持。所以std::allocator
应该支持C++ 17中的over-aligned类型。
uhm,N4659(我在www.open-std.org找到的pdf版本)仍然按照我的原始答案逐字读取,即全部类型支持是实现定义的... –
@MassimilianoJanes我在https://github.com/timsong-cpp/cppwp,不确定在www.open-std.org。 – Jamboree
ok阅读Marc Glisse的评论很清楚你是对的(很高兴知道分配函数现在也需要一个对齐参数)。 –
- 1. 为什么std :: allocator在C++ 17中失去成员类型/函数?
- 2. 为什么std :: allocator :: construct和std :: allocator :: destroy在元素类型上模板化?
- 3. 的std ::在C++ 17
- 4. std :: allocator上的Rambling
- 5. C++ 17 std :: G ++中可选?
- 6. std :: regex_match与另一个Allocator
- 7. C++中已过时的std :: is_literal_type 17
- 8. Windows上的C++ 17是否与Ubuntu上的C++ 17保持一致?
- 9. 是否std :: copy处理重叠范围?
- 10. 用std :: allocator释放分配
- 11. 什么是C++处理类模板及其类型的方式?
- 12. 为什么不是std :: string :: max_size()== std :: string :: allocator :: max_size()
- 13. C++ vector.push_back错误:请求成员'push_back'...,它是非类类型'vector(char,allocator(char))()()'
- 14. 是否使用C++标准所要求的allocator :: rebind?
- 15. 如何在C++ 17中使用std :: min_element?
- 16. 检查模板类型T是否属于C++中的变量参数包17
- 17. forward_list,set,list等如何调用std :: allocator?
- 18. 在C++中使用std :: allocator而不是新的优点是什么?
- 19. 为什么std :: allocator的构造和销毁函数在C++ 17中不推荐使用?
- 20. 处理C#中SQL的空类型
- 21. C#Math.Max类型处理
- 22. C++ 17中的std :: vector演绎指南是什么?
- 23. C++ 17中不赞成使用std :: result_of的原因是什么?
- 24. 的std ::插入替换C++ 17
- 25. 如何在我自己的容器类中使用std :: allocator
- 26. C + + 17中的std :: byte与C#中的byte相当吗?
- 27. C++ 17类模板扣除
- 28. fortran中是否有类似C中的预处理器指令?
- 29. C++ std :: allocator :: allocate()给我一个不好的指针
- 30. 如何检测类型是C中预处理器的指针?
oops,我删除了我的错误答案,复制粘贴的恐怖故事......(随意投票给我...... :)) –
是的,http://www.open-std.org/jtc1/ sc22/wg21/docs/papers/2016/p0035r4.html删除了使其实现定义的文本。 –
@MassimilianoJanes没关系,我已经找到了N4659(C++ 17 DIS)中的部分。 – Jamboree