docs: placement new 应在已分配的内存上构造对象

This commit is contained in:
liukai 2021-03-28 17:13:55 +08:00
parent ea416eed20
commit c40b848ebf

View File

@ -185,7 +185,7 @@ singleton *instance() {
lock_guard<mutex> guard(lock_);
if (p == nullptr) {
singleton *tmp = static_cast<singleton *>(operator new(sizeof(singleton)));
new(p)singleton();
new(tmp)singleton();
p = tmp;
}
}