title: Can be template function within class template specialized outside of the class template?
body: <p>Can be template function within class template specialized outside of the class template?
  What is the syntax for it?</p>
  
  <p>Following code gives <code>unable to match function definition to an existing declaration</code> in MSVC2010</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  template &lt;typename T&gt;
  struct Test
  {
      template &lt;typename S&gt;
      void test(const S &amp; t);
  
      //this works
      //template&lt;&gt; void test(const double &amp; t) { std::cout &lt;&lt; t &lt;&lt; "D \n"; }
  
      T member;
  };
  
  //this doesn't work
  template &lt;typename T&gt;
  template &lt;&gt;
  void Test&lt;T&gt;::test(const double &amp; t)
  {
      std::cout &lt;&lt; t &lt;&lt; "D \n";
  }
  
  int main()
  {
      Test&lt;int&gt; t;
      t.test(7.0);
  }
  </code></pre>
  
  <p><strong>edit</strong></p>
  
  <p>I can use overload as suggested in answers, because I use it little differently, here is how:</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  template &lt;typename T&gt;
  struct Test
  {
      template &lt;typename S&gt;
      void test() { std::cout &lt;&lt; "Any type \n"; }
  
      template &lt;&gt;
      void test&lt;double&gt;() { std::cout &lt;&lt; "Double! \n"; }
  
      T member;
  };
  
  int main()
  {
      Test&lt;int&gt; t1;
      Test&lt;int&gt; t2;
      t1.test&lt;float&gt;();
      t2.test&lt;double&gt;();
  }
  </code></pre>
  
  <p>and I want specialization for double outside of the <code>struct</code>. </p>
  
  <p>Why I use it like this you ask? In real scenario I have built factory class which is used like:</p>
  
  <pre><code>Factory&lt;SomePolicy&gt; f;
  f.create&lt;MyType&gt;(arg1, arg2, ...)
  </code></pre>
  
  <p>and I need specialization of <code>create</code> for specific type which won't pollute header file.</p>