title: calling template function of template base class
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/610245/where-and-why-do-i-have-to-put-the-template-and-typename-keywords">Where and why do I have to put the &ldquo;template&rdquo; and &ldquo;typename&rdquo; keywords?</a>  </p>
  </blockquote>
  
  
  
  <p>Here's the code:</p>
  
  <pre><code>template&lt;typename T&gt;
  class base
  {
  public:
      virtual ~base();
  
      template&lt;typename F&gt;
      void foo()
      {
          std::cout &lt;&lt; "base::foo&lt;F&gt;()" &lt;&lt; std::endl;
      }
  };
  
  template&lt;typename T&gt;
  class derived : public base&lt;T&gt;
  {
  public:
      void bar()
      {
          this-&gt;foo&lt;int&gt;(); // Compile error
      } 
  };
  </code></pre>
  
  <p>And, when running:</p>
  
  <pre><code>derived&lt;bool&gt; d;
  d.bar();
  </code></pre>
  
  <p>I get the following errors:</p>
  
  <pre><code>error: expected primary-expression before ‘int’
  error: expected ‘;’ before ‘int’
  </code></pre>
  
  <p>I'm aware of <a href="http://www.parashift.com/c++-faq-lite/templates.html#faq-35.19" rel="noreferrer">non-dependent names and 2-phase look-ups</a>. But, when the function itself is a template function (<code>foo&lt;&gt;()</code> function in my code), I tried all workarounds only to fail.</p>