This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Two-stage name lookup problem
- From: Jakub Pawlewicz <jakub dot pawlewicz at gmail dot com>
- To: gcc-help at gcc dot gnu dot org
- Date: Wed, 26 Oct 2005 09:18:33 +0200
- Subject: 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