问题描述
目标:了解动机,为什么C ++ 17引入std::aligned_alloc
用于动态内存管理。
问题:对于C ++中的内存分配,由于In what cases do I use malloc and/or new?中列举的各种原因,实际上始终不鼓励使用std::malloc
。相反,几乎总是鼓励在低级代码中使用new
表达式(例如,参见Notes)。
尽管有这种沮丧,我想知道为什么C ++ 17引入了std::aligned_alloc
,看起来像是std::malloc
的延续。
在C ++ 17(及更高版本)中,new
(或鼓励使用的其他等效实用程序,如果有)不能执行任何操作吗?
尝试:我只能找到以下仍与我的问题密切相关的讨论:
Difference between aligned malloc and standard malloc?