title: Unable to use custom allocator with allocate_shared/make_shared
body: <p>In my C++11 program, I use <code>shared_ptr&lt;T&gt;</code> for some objects which are actively created and deleted. It so happened that standard allocator with <code>operator new</code> is a bottleneck, so I want to create my own one, which will allocate a bunch of memory at once and then give to to <code>make_shared</code> on demand. Unfortunatelly, this is the first time I write an allocator and I have no idea why GCC is unable to compile the following code:</p>
  
  <pre><code>#include &lt;memory&gt;
  
  class MyAlloc {
  public:
    typedef char* pointer;
    typedef const char* const_pointer;
    typedef char value_type;
  
    char* allocate(size_t len) {
      return new char[len];
    }
  
    void deallocate(char *ptr) {
      delete[] ptr;
    }
  } my_alloc;
  
  int main() {
    std::allocator_traits&lt;MyAlloc&gt;();
    // MyAlloc is a correct allocator, since allocator_traits can be instantiated
    // If I comment the following line of code, compilation is successful
    std::allocate_shared&lt;int&gt;(my_alloc, 0);
    return 0;
  }
  </code></pre>
  
  <p>Here I have very simple stub allocator and one call to <code>allocate_shared</code>. The error GCC produces is:</p>
  
  <pre><code>In file included from c:\soft\mingw\lib\gcc\mingw32\4.8.1\include\c++\ext\alloc_traits.h:36:0,
                   from c:\soft\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_construct.h:61,
                   from c:\soft\mingw\lib\gcc\mingw32\4.8.1\include\c++\memory:64,
                   from a.cpp:1:
  c:\soft\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\alloc_traits.h: In substitution of 'template&lt;class _Alloc&gt; template&lt;class _Tp&gt; using rebind_traits = std::allocator_traits&lt;typename std::__alloctr_rebind&lt;_Alloc, _Tp&gt;::__type&gt; [with _Tp = std::_Sp_counted_ptr_inplace&lt;int, MyAlloc, (__gnu_cxx::_Lock_policy)2u&gt;; _Alloc = MyAlloc]':
  c:\soft\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\shared_ptr_base.h:517:33:   required from 'std::__shared_count&lt;_Lp&gt;::__shared_count(std::_Sp_make_shared_tag, _Tp*, const _Alloc&amp;, _Args&amp;&amp; ...) [with _Tp = int; _Alloc = MyAlloc; _Args = {int}; __gnu_cxx::_Lock_policy _Lp = (__gnu_cxx::_Lock_policy)2u]'
  c:\soft\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\shared_ptr_base.h:986:35:   required from 'std::__shared_ptr&lt;_Tp, _Lp&gt;::__shared_ptr(std::_Sp_make_shared_tag, const _Alloc&amp;, _Args&amp;&amp; ...) [with _Alloc = MyAlloc; _Args = {int}; _Tp = int; __gnu_cxx::_Lock_policy _Lp = (__gnu_cxx::_Lock_policy)2u]'
  c:\soft\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\shared_ptr.h:316:64:   required from 'std::shared_ptr&lt;_Tp&gt;::shared_ptr(std::_Sp_make_shared_tag, const _Alloc&amp;, _Args&amp;&amp; ...) [with _Alloc = MyAlloc; _Args = {int}; _Tp = int]'
  c:\soft\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\shared_ptr.h:598:39:   required from 'std::shared_ptr&lt;_Tp1&gt; std::allocate_shared(const _Alloc&amp;, _Args&amp;&amp; ...) [with _Tp = int; _Alloc = MyAlloc; _Args = {int}]'
  a.cpp:19:40:   required from here
  c:\soft\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\alloc_traits.h:204:66: error: invalid use of incomplete type 'struct std::__alloctr_rebind&lt;MyAlloc, std::_Sp_counted_ptr_inplace&lt;int, MyAlloc, (__gnu_cxx::_Lock_policy)2u&gt;, false&gt;'
           using rebind_traits = allocator_traits&lt;rebind_alloc&lt;_Tp&gt;&gt;;
                                                                    ^
  c:\soft\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\alloc_traits.h:65:12: error: declaration of 'struct std::__alloctr_rebind&lt;MyAlloc, std::_Sp_counted_ptr_inplace&lt;int, MyAlloc, (__gnu_cxx::_Lock_policy)2u&gt;, false&gt;'
       struct __alloctr_rebind;
              ^
  </code></pre>
  
  <p>Why does this happen? How do I write allocators correctly so that they work with <code>allocate_shared</code>? I know that there are some other operators and type traits that are to be supported by allocator, but I cannot see any hint about what does GCC want from me.</p>
  
  <p>Also, is it OK to use <code>char</code> as <code>value_type</code> for this particular allocator (in conjunction with <code>shared_ptr</code>) or something like <code>void</code> or <code>shared_ptr&lt;T&gt;::some_weird_stuff</code> is preferrable?</p>