title: template specialization of template class
body: <p>I want to specialize following member function:</p>
  
  <pre><code>class foo {
      template&lt;typename T&gt;
      T get() const;
  };
  </code></pre>
  
  <p>To other class <code>bar</code> that depends on templates as well. </p>
  
  <p>For example, I would like <code>bar</code> to be <code>std::pair</code> with some template parameters, something like that:</p>
  
  <pre><code>template&lt;&gt;
  std::pair&lt;T1,T2&gt; foo::get() const
  {
      T1 x=...;
      T2 y=...;
      return std::pair&lt;T1,T2&gt;(x,y);
  }
  </code></pre>
  
  <p>Where T1 and T2 are templates as well. How can this be done? As far as I know it should be
  possible.</p>
  
  <p>So now I can call:</p>
  
  <pre><code>some_foo.get&lt;std::pair&lt;int,double&gt; &gt;();
  </code></pre>
  
  <p><strong>The full/final answer:</strong></p>
  
  <pre><code>template&lt;typename T&gt; struct traits;
  class foo {
      template&lt;typename T&gt;
      T get() const
      {
         return traits&lt;T&gt;::get(*this); 
      }
  };
  
  template&lt;typename T&gt;
  struct traits {
      static T get(foo &amp;f)
      {
          return f.get&lt;T&gt;();
      }
  };
  
  template&lt;typename T1,typename T2&gt;
  struct traits&lt;std::pair&lt;T1,T2&gt; &gt; {
          static std::pair&lt;T1,T2&gt; get(foo &amp;f)
          {
                  T1 x=...;
                  T2 y=...;
                  return std::make_pair(x,y);
          }
  };
  </code></pre>