I found a workaround. It looks ugly, but it works. I used dummy template arguments to overcome instantiation. I hope somebody will find a nicer solution. Here is a hacked code: template <typename Dummy> struct A_impl; typedef A_impl<void> A; template <typename Dummy> struct A_impl { int x; A_impl(int x) : x(x) { } template <int X, typename Dummy2> struct B { A_impl<Dummy2> a; B() : a(X) { } void f() { } }; template <int X> void f() { B<X, Dummy> b; b.f(); } }; int main() { A a(0); a.f<0>(); } 2005/10/26, Jakub Pawlewicz <jakub.pawlewicz@xxxxxxxxx>: > 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 >