Re: Is it me or is it gcc?
On Sep 12, 2:22 pm, Boltar <boltar2...@yahoo.co.uk> wrote:
On Sep 12, 12:24 pm, Michael DOUBEZ <michael.dou...@free.fr> wrote:
Look up template-dependant
name:http://www.parashift.com/c++-faq-lite/templates.html#faq-35.19
Thats just retarded. What idiot thought that up? Why would I
want "this->" in front of every inherited variable and class,
I might just as well code in C!
The problem is just the opposite. Suppose you have something
like:
extern int wibble ;
template< typename T >
class U : public T
{
public:
int f() { return wibble ; }
} ;
Now what happens if T contains a member wibble? (That's the
official reason---I'm not saying I agree with it.)
It has nothing to do with base classes or inheritance. It has
to do with whether the expression depends on the template
arguments or not. Without reason to do otherwise, "wibble",
used alone, doesn't depend on the template arguments, so is
looked up (and bound) immediately. Putting this-> in front of
it makes it depend on the template arguments (if there is a base
class which depends on the template arguments), so name lookup
and binding is deferred to instantiation time.
I thought 4.2.1 would throw an error.
Perhaps the guys at GNU realise what a PITA this is and
removed the check.
I don't think so, but who knows.
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S=E9mard, 78210 St.-Cyr-l'=C9cole, France, +33 (0)1 30 23 00 34