title: C++ custom allocator
body: <p>Hi I have written a custom allocator with the help of some resources. It works fine for std::vector, list . However for std::unordered_map the constructor gets called twice . I am not why. Can someone please help me understand the static initialization that is happening. Here's the code </p>
  
  <p>File:helper.h</p>
  
  <pre><code>template&lt;typename T&gt;
  class helper
  {
   static const size_t init_size = 12; // 0xF4240 max number of entries in the data structure
  public:
        helper() :
        alloc_size(
        sizeof(link) &gt; sizeof(T) ?
        init_size * sizeof(link) : init_size * sizeof(T)), offset(
        sizeof(link) &gt; sizeof(T) ? sizeof(link) : sizeof(T))
    {
         std::cout &lt;&lt;"Initial allocation done" &lt;&lt; " I value : " &lt;&lt; i &lt;&lt; std::endl;
     }
  
  
  };
  </code></pre>
  
  <p>File: main.cpp</p>
  
  <pre><code>int main()
  {
      std::unordered_map&lt;long,long,hash&lt;long&gt;, equal_to&lt;long&gt; , myallocator&lt;pair&lt;const long,long&gt; &gt; &gt;            my_map;
  }
  </code></pre>
  
  <p>calling it that way makes the <strong>helper</strong> constrcutor get called twiced in the program. It doesn'y happen like that for vector. Is there something i am not understanding with regards to template initialization. Please help</p>