title: specialize template<typename T, template<typename> class U>
body: <p>I have a problem with nested templates and their template specialization. Given the following classes:</p>
  
  <p>A small template class</p>
  
  <pre><code>template&lt;class U&gt;
  class T {
  public:
      T(){}
      virtual ~T (){}
  
  };
  </code></pre>
  
  <p>And some kind of nested template</p>
  
  <pre><code>template&lt;typename T, template&lt;typename&gt; class U&gt;
  class A {
  public:
      void foo() 
      { 
          std::cerr &lt;&lt; "A generic foo"; 
      }
  };
  </code></pre>
  
  <p>And a small main.cpp</p>
  
  <pre><code>int main(int argc, const char *argv[])
  {
      A&lt;int,T&gt; *a = new A&lt;int,T&gt;;
      a-&gt;foo();
  
      //This wont work:
      A&lt;double,T*&gt; *b = new A&lt;double,T*&gt;;
      b-&gt;foo();
  
      return 0;
  }
  </code></pre>
  
  <p>Now I need a specialization if U is a pointer:</p>
  
  <pre><code>    A&lt;double,T*&gt; *b = new A&lt;double,T*&gt;;
      b-&gt;foo();
  </code></pre>
  
  <p>How to achieve this? I tried something like:</p>
  
  <pre><code>template&lt;typename T, template&lt;typename&gt; class U&gt;
  class A&lt; T, U* &gt;
  {
  public:
  void foo()
  {
      std::cerr &lt;&lt; "A specialized foo";
  }
  };
  </code></pre>
  
  <p>But it just resolves in</p>
  
  <pre><code>A.h:18:16: Error: Templateargument 2 is invalid
  </code></pre>