This is the mail archive of the gcc@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]

Re: gcc-3.4 requires 'typename' to use map in a template?


On Thu, 02 Oct 2003 17:29:40 -0700, Dan Kegel <dkegel@ixiacom.com> said:
> Dan Kegel wrote:

>> #include <map>
>> template <typename T>
>> class myclass {
>> typedef std::map<T, unsigned int> mymap;
>> public:
>> void mymethod() {
>> typename mymap::iterator myvar;
>> myvar = 0;
>> }
>> };
>> So is gcc-3.4-20031001 right to require typename here, or is this a
>> bug?

> The local language lawyer says yep, gcc-3.4 could be right;
> since mymap depends on T, it needs the 'typename'.
> But shoot, you'd *think* a typedef would be enough of a clue!

My understanding is that it's not that it needs help figuring out that
mymap is a type, it needs help figuring out that mymap::iterator is a
type.  (Which it might or might not be for different values of T, if
you inserted some particularly perverse specializations of std::map.)

David Carlton
carlton@kealia.com


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