Two-stage name lookup problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux