title: 'Primary-expression expected' error not using dependent type
body: <p>In the following code, the 'bObj->b()' line in main() compiles but the 'cObj->c()' line gives an error 'expected primary-expression before '>' token'.  This doesn't have to do with dependent types; adding 'template' or 'typename' in the appropriate place doesn't help.  Any hint on what the problem is?  In the 'real' version of this code, there are many other template and non-template versions of function 'b'.  The problem may be only occur in one place and not others, but I haven't been able to determine what may be the important difference.</p>
  
  <pre><code>#include &lt;boost/shared_ptr.hpp&gt;
  
  class A {};
  class D : public A {};
  
  class B
  {
  public: 
          template &lt;class T&gt; boost::shared_ptr&lt;T&gt; b() { return boost::shared_ptr&lt;T&gt;(); }
  };      
  
  class C
  {
  public: 
          boost::shared_ptr&lt;A&gt; b() { return boost::shared_ptr&lt;A&gt;(); }
  };      
  
  int main(int, char **)
  {       
          boost::shared_ptr&lt;C&gt; cObj(new C);
          boost::shared_ptr&lt;B&gt; bObj = boost::dynamic_pointer_cast&lt;B&gt;(cObj);
  
          bObj-&gt;b&lt;D&gt;();
          cObj-&gt;b&lt;D&gt;();
  }    
  </code></pre>