使用placement new的返回值和其操作数的转换值之间是否存在(语义)差异?
struct Foo { ... };
char buffer[...];
Foo *a = new(buffer) Foo;
Foo *b = reinterpret_cast<Foo *>(buffer);
a
和 b
是否存在差异?
根据DaBler的评论,这个问题告诉我们,如果使用const或引用成员: Placement new and assignment of class with const member
那么,稍微更新一下问题: 如果Foo
没有const或引用成员,a
和b
是否有任何不同?