gcc-3.4 requires 'typename' to use map in a template?
David Carlton
carlton@kealia.com
Fri Oct 3 00:51:00 GMT 2003
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
More information about the Gcc
mailing list