gcc is right to reject this code, something more standard compliant should pass :
for(typename B::iterator i; ...)
Yep, conveniently, gcc-3.4.3 even suggests it:
a.cpp:29: error: dependent-name ` B::iterator' is parsed as a non-type, but instantiation yields a type a.cpp:29: note: say `typename B::iterator' if a type is meant
But still I don't get why this is wrong. Is only because the compiler can't tell whether it's a typename or something else at parse time?
btw, take care with "parent<std::list<int>>". Apparently GCC now gets it right, but to be portable, better write "parent<std::list<int> >", to avoid parsing a shift operator instead.
Cheers, jlh
Attachment:
signature.asc
Description: OpenPGP digital signature