Template method of template class specialization <p>Here is my code:</p> <pre><code>template&lt;typename T1, typename T2&gt; class MyClass { public: template&lt;int num&gt; static int DoSomething(); }; template&lt;typename T1, typename T2&gt; template&lt;int num&gt; int MyClass&lt;T1, T2&gt;::DoSomething() { cout &lt;&lt; "This is the common method" &lt;&lt; endl; cout &lt;&lt; "sizeof(T1) = " &lt;&lt; sizeof(T1) &lt;&lt; endl; cout &lt;&lt; "sizeof(T2) = " &lt;&lt; sizeof(T2) &lt;&lt; endl; return num; } </code></pre> <p>It works well. But when I try to add this</p> <pre><code>template&lt;typename T1, typename T2&gt; template&lt;&gt; int MyClass&lt;T1, T2&gt;::DoSomething&lt;0&gt;() { cout &lt;&lt; "This is ZERO!!!" &lt;&lt; endl; cout &lt;&lt; "sizeof(T1) = " &lt;&lt; sizeof(T1) &lt;&lt; endl; cout &lt;&lt; "sizeof(T2) = " &lt;&lt; sizeof(T2) &lt;&lt; endl; return num; } </code></pre> <p>I get compiller errors: invalid explicit specialization before «>» token template-id «DoSomething&lt;0>» for «int MyClass::DoSomething()» does not match any template declaration</p> <p>I use g++ 4.6.1 What should I do?</p>