This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Two-stage name lookup problem


I have problem with templates and I need a solution. I want to use
inner class B with a member of outer class A type. Then I wand class A
to use template class B in function f. Here is code I want to change
in order to compile with gcc 3.4. It compiles fine with gcc 3.3.

struct A {
 int x;
 A(int x) : x(x) { }

 template <int X>
 struct B {
   A a;
   B() : a(X) { }
   void f() { }
 };

 template <int X>
 void f()
 {
   B<X> b;
   b.f();
 }
};

int main()
{
 A a(0);
 a.f<0>();
}

Compilation fails with a message
a.cpp:7: error: field `a' has incomplete type
a.cpp: In constructor `A::B<X>::B()':
a.cpp:8: error: class `A::B<X>' does not have any field named `a'

Is there any workaround?

Thanks in advance

Jakub Pawlewicz


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]