title: explicit specialization of template class member function
body: <p>I need to specialize template member function for some type (let's say <strong>double</strong>). It works fine while class <code>X</code> itself is not a template class, but when I make it template GCC starts giving compile-time errors.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;cmath&gt;
  
  template &lt;class C&gt; class X
  {
  public:
     template &lt;class T&gt; void get_as();
  };
  
  template &lt;class C&gt;
  void X&lt;C&gt;::get_as&lt;double&gt;()
  {
  
  }
  
  int main()
  {
     X&lt;int&gt; x;
     x.get_as();
  }
  </code></pre>
  
  <p>here is the error message</p>
  
  <pre><code>source.cpp:11:27: error: template-id
    'get_as&lt;double&gt;' in declaration of primary template
  source.cpp:11:6: error: prototype for
    'void X&lt;C&gt;::get_as()' does not match any in class 'X&lt;C&gt;'
  source.cpp:7:35: error: candidate is:
    template&lt;class C&gt; template&lt;class T&gt; void X::get_as()
  </code></pre>
  
  <p>How can I fix that and what is the problem here?</p>
  
  <p>Thanks in advance.</p>