views:

210

answers:

1

You may have notice that later versions of gcc is more strict with standards (see this question)

All inherited members of a template class should be called using the full name, ie. ParentClass<T>::member instead of just member

But still I have a lot of old code that does not respect this. Adding using ParentClass<T>::member for each used member in each class is quite a pain. Is there is a way to do something like using ParentClass<T>::* ?. I would like this better than deactivating this check in g++ but if there is now way, how can I deactivate it ?

Edit:

According to C++ FAQ (thanks sth) these are the only way to correctly solve the inherited member variable names :

  1. Change the call from f() to this->f(). Since this is always implicitly dependent in a template, this->f is dependent and the lookup is therefore deferred until the template is actually instantiated, at which point all base classes are considered.

  2. Insert using B<T>::f; just prior to calling f().

  3. Change the call from f() to B<T>::f().

So now looking for the right switch to deactivate the full name resolution ...

+5  A: 

Not really an answer to you question, but you can also write this->member instead of ParentClass<T>::member. This is most often easier to write and makes the compiler look for member in the right places.

sth