c++/9380: nested template problem for methods without argument : parsing error

lerdsuwa@gcc.gnu.org lerdsuwa@gcc.gnu.org
Tue Jan 21 14:15:00 GMT 2003


Synopsis: nested template problem for methods without argument : parsing error

State-Changed-From-To: open->closed
State-Changed-By: lerdsuwa
State-Changed-When: Tue Jan 21 14:15:05 2003
State-Changed-Why:
    Not a bug.  Your code inside 'foo_2':
      a.how_many<Vertex>();
    'a' depends on the template parameter 'dim' so the compiler
    doesn't know if 'how_many' is a variable, a type, or a
    template.  For example, you can declare a specialization
      template<> class A<Volumn> { int how_many; }
    Then 'A<Vertex>.how_many' is a template function but
    'A<Volumn>.how_many' is a variable.  
    
    When you are referring to a template when the context is 
    template parameter dependent, you need the 'template' 
    keyword as in:
      a.template how_many<Vertex>();
    The same applies to the example in the Fix section:
      a.template how_many<Vertex>(id_foo<Vertex>());

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=9380



More information about the Gcc-prs mailing list