title: C++: "expected ;" in declaration in template
body: <p>I've been running into the following problem inside a member function of a templated class:</p>
  
  <pre><code>#include &lt;map&gt;
  using std::map;
  template &lt;typename A,typename B&gt;
  class C {
    public:
      B f(const A&amp;,const B&amp;) const;
    private:
      map&lt;A,B&gt; D;
  };
  template &lt;typename A,typename B&gt;
  B C&lt;A,B&gt;::f(const A&amp;a,const B&amp;b) const {
     map&lt;A,B&gt;::const_iterator x = D.find(a);
     if(x == D.end())
       return b;
     else
       return x-&gt;second;
  }
  </code></pre>
  
  <p>When I have g++ compile this I get the following error:</p>
  
  <pre><code>Bug.C: In member function 'B C&lt;A,B&gt;::f(const A&amp;, const B&amp;) const':
  Bug.C:12: error:expected ';' before 'x'
  Bug.C:13: error: 'x' was not declared in this scope
  </code></pre>
  
  <p>However, when I make a non-templated version of the class and function, with A and B both being int it compiles without a problem.  The error is a little mystifying since I can't imagine why it wants a ';' before the 'x'.</p>