title: Are there any problems with this overload of operator new?
body: <p>I was thinking about some memory pool/allocation stuff I might write so I came up with this <code>operator new</code> overload that I want to use to facilitate reuse of memory. I'm wondering if there are any problems you guys can think of with my implementation (or any other possible ones).</p>
  
  <pre><code>#include &lt;cstddef&gt;
  
  namespace ns {
      struct renew_t { };
      renew_t const renew;
  }
  
  template&lt;typename T&gt;
  inline void * operator new(std::size_t size, T * p, ns::renew_t renew_constant) {
      p-&gt;~T();
      return p;
  }
  
  template&lt;typename T&gt;
  inline void operator delete(void *, T *, ns::renew_t renew_constant) { }
  </code></pre>
  
  <p>It can be used like this</p>
  
  <pre><code>int main() {
      foo * p(new foo());        // allocates memory and calls foo's default constructor
      new(p, ns::renew) foo(42); // calls foo's destructor, then calls another of foo's constructors on the same memory
      delete p;                  // calls foo's destructor and deallocates the memory
  }
  </code></pre>