简体   繁体   English

布局和非布局分配器

[英]Placement and non-placement allocators

What are the placement and non-placement allocation/deallocation function? 布局和非布局分配/取消分配功能是什么? I've been reading sec. 我一直在读秒。 3.7.4.2 of N3797 and come across with the placement and non-placement allocation / deallocation function concepts. 在N3797的3.7.4.2中,遇到了布局非布局 分配 / 取消分配功能的概念。 For instance: 例如:

The global operator delete with exactly one parameter is a usual ( non-placement ) deallocation function. 仅使用一个参数的全局运算符delete是通常的( 非放置 )释放函数。

I could not find a definition of these concepts and I assume that non-placement is the functions which have one of the following signature: 我找不到这些概念的定义,并且我假设非放置是具有以下签名之一的函数:

void* operator new(std::size_t);
void* operator new[](std::size_t);
void operator delete(void*);
void operator delete[](void*);
void operator delete(void*, std::size_t) noexcept;
void operator delete[](void*, std::size_t) noexcept;

Have I understood correctly? 我理解正确吗?

The definition of placement new is in N3797 in section 5.3.4.13 : 新放置的定义在N3797的第5.3.4.13节中:

The new-placement syntax is used to supply additional arguments to an allocation function. new-placement语法用于向分配函数提供其他参数。 If used, overload resolution is performed on a function call created by assembling an argument list consisting of the amount of space requested (the first argument) and the expressions in the new-placement part of the new-expression (the second and succeeding arguments). 如果使用重载解析,则对通过组合参数列表创建的函数调用执行重载解析,该参数列表由请求的空间量(第一个参数)和new-expression的new-placement部分中的表达式(第二个及后续参数)组成。 The first of these arguments has type std::size_t and the remaining arguments have the corresponding types of the expressions in the new-placement. 这些参数中的第一个参数的类型为std :: size_t,其余的参数在new-placement中具有相应的表达式类型。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM