将原始运营商new,placement new和standard delete合并是否合法?

glo*_*and 5 c++ memory-management new-operator

伙计们!出于好奇 - 以下代码可能不合法,是吗?

T *p = ::operator new(sizeof(T)); // allocate memory for a T
new (p) T; // construct a T into the allocated memory
delete p; //delete the object using the standard delete operator
Run Code Online (Sandbox Code Playgroud)

Pup*_*ppy 7

不,你只能delete从中得到回报new- 没有例外.