1.1.3.5 placement new
  • construct an object in memory you’ve already got a pointer to ,use placement new. If you use placement new to create an object in some memory, you should avoid using the delete operator on that memory. Detail can be seen in C++ primer
    p1 = new(buffer) FOO(); 
    p2 = new(buffer+sizeof(FOO) ) FOO(); 
     
    p1->~FOO(); // call dtor directly, 
    p2->~FOO(); //dont call delete p1. 
     
    delete[] buffer;
  • A good article is "The many faces of operator new in C++", It give detail information about operator new and how to rewrite it. I have added it to my ref.