title: Using STL Allocator with STL Vectors
body: <p>Here's the basic problem.  There's an API which I depend on, with a method using the following syntax:</p>
  
  <pre><code>void foo_api (std::vector&lt;type&gt;&amp; ref_to_my_populated_vector);
  </code></pre>
  
  <p>The area of code in question is rather performance intensive, and I want to avoid using the heap to allocate memory.  As a result, I created a custom allocator which allocates the memory required for the vector on the stack.  So, I can now define a vector as:</p>
  
  <pre><code>// Create the stack allocator, with room for 100 elements
  my_stack_allocator&lt;type, 100&gt; my_allocator;
  
  // Create the vector, specifying our stack allocator to use
  std::vector&lt;type, my_stack_allocator&gt; my_vec(my_allocator);
  </code></pre>
  
  <p>This is all fine.  Performance tests using the stack allocated vector compared to the standard vector show performance is roughly 4x faster.  The problem is, I can't call foo_api!  So...</p>
  
  <pre><code>foo_api(my_vec); // Results in an error due to incompatible types.
  // Can't convert std::vector&lt;type&gt; to std::vector&lt;type, allocator&gt;
  </code></pre>
  
  <p>Is there a solution to this? </p>