title: Use of std::allocator_traits<A>
body: <p>I would like to design a class template which takes an allocator type (as defined in Standard section 17.6.3.5) as a template argument.  I see how <code>std::allocator_traits&lt;A&gt;</code> helpfully fills in any missing members of <code>A</code> with default settings.  Beyond that, is there anything in the Standard Library or boost that would help use the allocator correctly?</p>
  
  <p>In particular:</p>
  
  <ol>
  <li><p>To honor the typedefs like <code>std::allocator_traits&lt;A&gt;::propagate_on_container_copy_assignment</code>, do I have to check these things in the special member functions of each class which has a member of type <code>A</code>?  Or is there some wrapper type I could use as a member instead which would take care of this stuff?</p></li>
  <li><p>If I want to overallocate to reduce the number of allocations by storing extra data next to the user-visible objects, is it appropriate to rebind the allocator something like this?</p></li>
  </ol>
  
  <p>.</p>
  
  <pre><code>template&lt;typename T, typename A&gt;
  class MyClass
  {
  private:
      //...
      struct storage {
          int m_special_data;
          T m_obj;
      };
      typedef typename std::allocator_traits&lt;A&gt;::template rebind_alloc&lt;storage&gt;
          storage_alloc;
      typedef typename std::allocator_traits&lt;A&gt;::template rebind_traits&lt;storage&gt;
          storage_traits;
      storage_alloc m_alloc;
  
      static T* alloc(T&amp;&amp; obj)
      {
          storage_traits::pointer sp = storage_traits::allocate(m_alloc, 1);
          sp-&gt;m_special_data = 69105;
          return ::new(&amp;sp-&gt;m_obj) T(std::move(obj));
      }
      //...
  };
  </code></pre>