title: Custom allocator including placement new case
body: <p>I'm trying to implement a custom allocator for C++ that works on any form of new/delete/malloc/free.<br> <br>How my program works, I allocate at the start of the program a memory pool of x bytes and work with them. For example, when someone writes <code>int* a= new int;</code> my program will return the address from the memory pool which is available and marks it as allocated and that address along with the size allocated is removed from the memory pool. When someone writes <code>delete a;</code> the address is returned to the memory pool and can be used again.<br><br> <strong>My problem is that I don't fully understand how <code>new(placement)</code> works and how should I deal with it</strong>, because when my function gets called to allocate memory on new/malloc I have as a parameter only the size of the memory the program needs and I just return an available address to that memory to be used. Consider the following example</p>
  
  <pre><code>auto p = (std::string*)malloc(5 * sizeof(std::string));
  void * placement = p;
  new(placement) std::string(4, (char)('a'));
  std::cout&lt;&lt; *p;
  </code></pre>
  
  <p>On the first line my custom allocated will return to p an address from my memory pool where there is memory available of a total of <code>5* sizeof(std::string))</code>, on the third line my custom allocator will allocate again memory returning another address. When I print <code>*p</code> it prints exactly what I was expected <code>aaaa</code>. <br><br>
  <strong>Is this how it should work?</strong></p>