This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/13270] Failed compile of template function in template class called from another template


------- Additional Comments From giovannibajo at libero dot it  2003-12-02 12:57 -------
Your code is invalid, you should use:

   Set s(Test<Allocator>::template MakeSet<Set>(a));

"template" keyword is needed when naming a dependent template-id in a postfix-
expression within a template definition. 

Delegalising this, the compiler needs to know that "MakeSet" is a template to 
be able to understand that the following "<" is the start of a template 
argument list (otherwise, it's just a minor sign). But the compiler cannot find 
it out at parsing time because Test<Allocator> depends on the template 
parameter "Allocator", which is unknown until instantiation. You could have 
some specializations in which Test<Allocator>::MakeSet is an enum, for instance.

By adding the template keyword, you tell the parser that MakeSet, in that 
context, is and always be a template.

By the way, 2 days ago GCC 3.4 was updated to provide a helpful error message 
describing this problem. I suggest you to update the compiler and try again to 
see the new error message.

Nonetheless, the code is invalid and correctly rejected by GCC.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13270


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]