title: Default values in templates with template arguments ( C++ )
body: <p>Assume I have a template (called ExampleTemplate) that takes two arguments: a container type (e.g. list, vector) and a contained type (e.g. float, bool, etc). Since containers are in fact templates, this template has a template param. This is what I had to write:</p>
  
  <pre><code>#include &lt;vector&gt;
  #include &lt;list&gt;
  
  using namespace std;
  
  template &lt; template &lt;class,class&gt; class C, typename T&gt;
  class ExampleTemplate {
      C&lt;T,allocator&lt;T&gt; &gt; items;
  public:
      ....
  };
  
  main()
  {
      ExampleTemplate&lt;list,int&gt; a;
      ExampleTemplate&lt;vector,float&gt; b;
  }
  </code></pre>
  
  <p>You may ask what is the "allocator" thing about. Well, Initially, I tried the obvious thing...</p>
  
  <pre><code>template &lt; template &lt;class&gt; class C, typename T&gt;
  class ExampleTemplate {
      C&lt;T&gt; items;
  };
  </code></pre>
  
  <p>...but I unfortunately found out that the default argument of the allocator...</p>
  
  <pre><code>   vector&lt;T, Alloc&gt;
     list&lt;T, Alloc&gt;
     etc
  </code></pre>
  
  <p>...had to be explicitely "reserved" in the template declaration.
  This, as you can see, makes the code uglier, and forces me to reproduce the default values of the template arguments (in this case, the allocator).</p>
  
  <p>Which is <em>BAD</em>.</p>
  
  <p><strong>EDIT:</strong> The question is not about the specific problem of containers - it is about "Default values in templates with template arguments", and the above is just an example. Answers depending on the knowledge that STL containers have a "::value_type" are not what I am after. Think of the generic problem: if I need to use a template argument C in a template ExampleTemplate, then in the body of ExampleTemplate, do I have to reproduce the default arguments of C when I use it? If I <em>have</em> to, doesn't that introduce unnecessary repetition and other problems (in this case, where C is an STL container, portability issues - e.g. "allocator" )?</p>