为什么 C++17 引入了 std::aligned_alloc?
Why did C++17 introduce std::aligned_alloc?
目标: 了解 C++17 为动态内存管理引入 std::aligned_alloc
的动机。
问题: 对于 C++ 中的内存分配,由于 In what cases do I use malloc and/or new?. Instead, using new
expression is almost always encouraged in low-level code (e.g. see Notes 下举例说明的各种原因,实际上总是不鼓励使用 std::malloc
。
尽管有这种沮丧,但我想知道为什么 C++17 引入了 std::aligned_alloc
,它看起来像是 std::malloc
.
的延续
C++17(及更高版本)中是否存在 new
(或鼓励使用的其他等效实用程序,如果有的话)无法执行的内容?
尝试:我只能找到以下讨论,它仍然与我的问题有很大关系:
C++17 将其对纯 C 的支持从 C99 提高到 C11。它继承了 aligned_alloc
以及 C11 的其他内容。
论文:http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0063r3.html
所以动机是让 C++ 中的 C 特性可供需要它们的人使用。
目标: 了解 C++17 为动态内存管理引入 std::aligned_alloc
的动机。
问题: 对于 C++ 中的内存分配,由于 In what cases do I use malloc and/or new?. Instead, using new
expression is almost always encouraged in low-level code (e.g. see Notes 下举例说明的各种原因,实际上总是不鼓励使用 std::malloc
。
尽管有这种沮丧,但我想知道为什么 C++17 引入了 std::aligned_alloc
,它看起来像是 std::malloc
.
C++17(及更高版本)中是否存在 new
(或鼓励使用的其他等效实用程序,如果有的话)无法执行的内容?
尝试:我只能找到以下讨论,它仍然与我的问题有很大关系:
C++17 将其对纯 C 的支持从 C99 提高到 C11。它继承了 aligned_alloc
以及 C11 的其他内容。
论文:http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0063r3.html
所以动机是让 C++ 中的 C 特性可供需要它们的人使用。