title: How to use boost::object_pool with std::unique_ptr?
body: <p>This is a two part question illustrated by the following code:</p>
  
  <pre><code>#include &lt;memory&gt;
  #include &lt;vector&gt;
  #include &lt;boost/pool/object_pool.hpp&gt;
  
  struct Foo {
     Foo(int i) : _i(i) {}
     void* operator new(size_t) = delete; // ***
     int _i;
   };
  
   using FooHandle = std::unique_ptr&lt;Foo&gt;;
  
   struct Bar {
      Foo* addFoo(int i) 
      {
        Foo* ptr = new (_fooPool.malloc()) Foo(i);             // 111
        return FooHandle(ptr, 
          &amp;boost::object_pool&lt;Foo,  
           boost::default_user_allocator_new_delete&gt;::destroy); // 222
      }
      boost::object_pool&lt;Foo&gt; _fooPool;
   };
  </code></pre>
  
  <p>I am trying to ensure that </p>
  
  <ol>
  <li>objects of type Foo are allocated and owned only by objects of type Bar, </li>
  <li>they are stored in pools, and </li>
  <li>they are accessed via unique pointers.</li>
  </ol>
  
  <p>Using the Visual Studio compiler I run into following problems</p>
  
  <ol>
  <li><p>If I delete the default operator new (line marked with ***) then placement new (line marked with 111) does not compile. Am I doing something wrong or is it a VS limitation?</p></li>
  <li><p>I imagine that in order to make a proper unique_ptr that was allocated in a pool I need to supply access to the pool deleter. The line marked as 222 is my attempt to do just that. The compiler does not accept it either. What is the correct syntax? </p></li>
  </ol>