Topic: Problems compiling template typedefs
Author: Nathan Myers <ncm@netcom.com>
Date: 1995/10/07 Raw View
"Douglas C. Schmidt" <schmidt@cs.wustl.edu> wrote:
> I get the following error:
>"y.C", line 17: Error: :: is not a class name as required for a qualifer.
>... when I compile the following program with SunC++ 4.0.1 and GNU G++:
> struct ACE_SOCK_Acceptor { typedef ACE_INET_Addr PEER_ADDR; };
>
> template <class PEER_ACCEPTOR>
> struct ACE_Acceptor { int open (const PEER_ACCEPTOR::PEER_ADDR &addr); };
> Can anyone tell me if there are compilers available that get this right?!
Correct C++ syntax would be
int open(const typename PEER_ACCEPTOR::PEER_ADDR& addr);
Unfortunately, I don't know of any compilers that accept the "typename"
keyword yet. (It's a fairly recent addition.) The "typename" keyword
is necessary to inform the lexer that the name is a type, both to help
decouple the parser from the lexer, and to permit some declarations that
would otherwise be terminally ambiguous.
Until the compilers come up to date, you will need to muddle along, doing
experiments to figure out what kind of heuristic (if any) your compiler
uses to identify type names in such contexts.
Nathan Myers
myersn@roguewave.com
[ comp.std.c++ is moderated. Submission address: std-c++@ncar.ucar.edu.
Contact address: std-c++-request@ncar.ucar.edu. The moderation policy
is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]