title: overload of template template function - explicit call
body: <p>So, first consider the following where template parameters are known implicitly from the function arguments:</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  class A {};
  class B {};
  
  template &lt;class T1, class T2&gt;
  class C { 
      T1 a; 
      T2 b; 
  };
  
  template &lt;class T1&gt;
  class D {
      T1 a;
  };
  
  template &lt;template&lt;class, class&gt; class TC, class TA, class TB&gt;
  void foo(TC&lt;TA, TB&gt; c) {
      std::cout &lt;&lt; "T&lt;T,T&gt;" &lt;&lt; std::endl;
  };
  
  template &lt;template&lt;class&gt; class TD, class TA&gt;
  void foo(TD&lt;TA&gt; d){
      std::cout &lt;&lt; "T&lt;T&gt;" &lt;&lt; std::endl;
  };
  
  int main() {
      C&lt;A,B&gt; c;
      D&lt;A&gt; d;
  
      foo(c);
      foo(d);
  }
  </code></pre>
  
  <p>And output is as you'd expect:</p>
  
  <pre><code>T&lt;T,T&gt;
  T&lt;T&gt;
  </code></pre>
  
  <p>However, what if I don't have an instance of class <code>C</code> and <code>D</code> so I need to explicitly call the correct overload?  How would this be done?  i.e., have a <code>main()</code> that consists of:</p>
  
  <pre><code>int main() {
      foo&lt;C&lt;A,B&gt; &gt;();
      foo&lt;D&lt;A&gt; &gt;();
  }
  </code></pre>
  
  <p>I've experimented with a few overloads of <code>foo()</code> as shown below:</p>
  
  <pre><code>template &lt;template&lt;class, class&gt; class TC&gt;
  void foo() {
      std::cout &lt;&lt; "T&lt;T,T&gt;" &lt;&lt; std::endl;
  };
  
  template &lt;template&lt;class&gt; class TD&gt;
  void foo(){
      std::cout &lt;&lt; "T&lt;T&gt;" &lt;&lt; std::endl;
  };
  
  template &lt;template&lt;class, class&gt; class TC, class TA, class TB&gt;
  void foo() {
      std::cout &lt;&lt; "T&lt;T,T&gt;" &lt;&lt; std::endl;
  };
  
  template &lt;template&lt;class&gt; class TD, class TA&gt;
  void foo(){
      std::cout &lt;&lt; "T&lt;T&gt;" &lt;&lt; std::endl;
  };
  </code></pre>
  
  <p>However, this (and all permutations I've been able to think of) simply results in a series of errors along the lines of the (abbreviated) output shown below</p>
  
  <pre><code>prog.cpp: In function 'int main()':
  prog.cpp:44:18: error: no matching function for call to 'foo()'
       foo&lt;C&lt;A,B&gt; &gt;();
                    ^
  prog.cpp:44:18: note: candidates are:
  prog.cpp:19:6: note: template&lt;template&lt;class, class&gt; class TC&gt; void foo()
   void foo() {
        ^
  prog.cpp:19:6: note:   template argument deduction/substitution failed:
  prog.cpp:24:6: note: template&lt;template&lt;class&gt; class TD&gt; void foo()
   void foo(){
        ^
  prog.cpp:24:6: note:   template argument deduction/substitution failed:
  </code></pre>
  
  <p>Is what I'm looking to do even allowable?  If so, where am I messing up?</p>
  
  <p><strong>---- EDIT ----</strong></p>
  
  <p>So as apple apple pointed out if my <code>main()</code> is as follows:</p>
  
  <pre><code>int main() {
      foo&lt;C, A, B&gt;();
      foo&lt;D, A&gt;();
  }
  </code></pre>
  
  <p>I get the output as expected.</p>
  
  <p>However, my real-world case winds up being more complex.  I'll expand a bit here.  The legacy code has (hundreds) of typedefs defined in headers elsewhere along the lines of:</p>
  
  <pre><code>typedef C&lt;A, B&gt; type_117;
  typedef D&lt;A&gt;    type_252;
  </code></pre>
  
  <p>The class I'm working on is templated and is instantiated with one of those typedefs as the templating argument.  So something along the lines of:</p>
  
  <pre><code>template &lt;class Type&gt;
  class Test
  {
  public:
     Test();
     SomeClass mSC;
  }
  Test::Test()
    : mSC(foo&lt;Type&gt;())
  {
  };
  </code></pre>
  
  <p>where Test was instantiated as </p>
  
  <pre><code>Test&lt;type_117&gt; aTest;
  </code></pre>
  
  <p>So I've been trying to figure out how to write <code>foo()</code> for this context.  At the point I call <code>foo()</code> within my <code>Test</code>'s initializer am I able to "decompose" it to produce the <code>&lt;C,A,B&gt;</code> form?  Or have I hit a roadblock and need to rework some of the existing framework?</p>