I recently upgraded my Linux system, which resulted in my version of gcc going from 3.3.2 to 3.4.2. Some header files that were working under 3.3.2 are now failing to compile in 3.4.2 due to the correction of a name lookup bug in the older compiler. A full description of the situation is given
here.
I'm now wondering what the most effective remedy to this is. It is suggested in the above link that one of two solutions are used: either insert a
this-> before each base class name, or explicitly bring the base class name into scope with
Base<T>:: .
Both of the these solutions are, to be honest, ugly. U-uh-glee. Beautifully clear code is now sprinkled with thises and thats or double colons. So being the adventurer I am, I tried
Code:
template <typename T> struct Base { int i; };
template <typename T> struct Derived : public Base<T> {
int get_i() { using namespace Base<T>; return i; }
};
But gcc returned an error
Quote:
error: expected identifier
error: expected `;'
error: declaration does not declare anything
|
Undaunted, I thought "Well, it's more work for me, but perhaps I can bring each name into scope at the start of each templated member function of the derived class". So I change the derived class to read
Code:
template <typename T> struct Derived : public Base<T> {
int get_i() { using Base<T>::i; return i; }
};
which gives me the error
Quote:
error: `Base<T>' is not a namespace
|
This is strange, since "inline" scope resolution like
Base<T>::i works. Why shouldn't a using-declaration work?
Anyone have any suggestions to unclutter my code? Is it
supposed to be this difficult to use non-dependent names from templated base classes in derived classes?
R.