Deriving from templated classes
John (Eljay) Love-Jensen
eljay@adobe.com
Fri Nov 16 15:37:00 GMT 2007
Hi Lothar,
>This seems strange to me, because i think "bar" and "foo" should be within the namespace of "class Bar".
Yep, I'd think so too. But that's not what the C++ standard says. :-(
> The code compiles if i substitute "bar++" with "Foo<A>::bar++" and "foo = 1" with "Foo<A>::foo = 1".
That's what the standards says you need to do.
There may be a few other alternatives, such as this->bar++ or "using" directive. I use the mechanism you used, so if the alternatives work I haven't actually tried them yet.
> I tried to compile the code snipplet above using compilers from diffrent vendors (intel and m$). Both compiled the code without any errors or warnings.
Then those compilers are non-compliant on this issue.
>My question is: Does gcc do the right thing (tm) or should that behavior reported as a bug?
On this matter, GCC is doing the right thing as per the C++ standard (ISO 14882). Older versions of GCC (3.x era?) were not compliant on this matter.
HTH,
--Eljay
More information about the Gcc-help
mailing list