title: C++ allocators, specifically passing constructor arguments to objects allocated with boost::interprocess::cached_adaptive_pool
body: <p>This is an embarrassing question, but even the well-written documentation provided with boost.interprocess hasn't been enough for me to figure out how to do this.</p>
  
  <p>What I have is a <a href="http://www.boost.org/doc/libs/1_42_0/doc/html/boost/interprocess/cached_adaptive_pool.html" rel="nofollow noreferrer">cached_adaptive_pool</a> allocator instance, and I want to use it to construct an object, passing along constructor parameters:</p>
  
  <pre><code>struct Test {
    Test(float argument, bool flag);
    Test();
  };
  
  // Normal construction
  Test obj(10, true);
  // Normal dynamic allocation
  Test* obj2 = new Test(20, false);
  
  typedef managed_unique_ptr&lt;
      Test, boost::interprocess::managed_shared_memory&gt;::type unique_ptr;
  
  // Dynamic allocation where allocator_instance == cached_adaptive_pool,
  // using the default constructor
  unique_ptr obj3 = allocator_instance.allocate_one()
  // As above, but with the non-default constructor
  unique_ptr obj4 = allocator_instance ... ???
  </code></pre>
  
  <p>This may very well be a failure on my part on how to use allocator objects in general. But in any case, I cannot see how to use this specific allocator, with the interface specified in <a href="http://www.boost.org/doc/libs/1_42_0/doc/html/boost/interprocess/cached_adaptive_pool.html" rel="nofollow noreferrer">cached_adaptive_pool</a> to pass constructor arguments to my object.</p>
  
  <p><code>cached_adaptive_pool</code> has the method: <code>void construct(const pointer &amp; ptr, const_reference v)</code> but I don't understand what that means and I can't find examples using it.</p>
  
  <p>My head has been swimming in templates all day, so a helping hand, even if the answer is obvious, will be greatly appreciated.</p>