1//placement new in c++
2char *buf = new char[sizeof(string)]; // pre-allocated buffer
3string *p = new (buf) string("hi"); // placement new
4string *q = new string("hi"); // ordinary heap allocation
5/*Standard C++ also supports placement new operator, which constructs
6an object on a pre-allocated buffer. This is useful when building a
7memory pool, a garbage collector or simply when performance and exception
8safety are paramount (there's no danger of allocation failure since the memory
9has already been allocated, and constructing an object on a pre-allocated
10buffer takes less time):
11*/