Hi,
The following compiles on g++ version 3.2.3 on Red Hat and HP-UX, but fails on 3.4.4 (cygming special). Since that appears to be newer I'm assuming it's my code that's wrong.
I've cut it down to this example
The error I get isCode:#include <vector> #include <iterator> #include <memory> template <typename T1> class Foo; template<typename T1> class FooItr { public: typedef std::auto_ptr< FooItr<T1> > Ptr; public: FooItr<T1>(Foo<T1>* pFoo) : m_itr(pFoo->m_list.begin()) { } virtual ~FooItr() { } protected: typename Foo<T1>::FooList::const_iterator m_itr; }; template<typename T1> class Foo { public: virtual typename FooItr<T1>::Ptr getItr() { return FooItr<T1>::Ptr(new FooItr<T1>(this)); } protected: friend class FooItr<T1>; typedef std::vector<T1> FooList; FooList m_list; }; int main() { Foo<int>* p = new Foo<int>(); delete p; return 0; }If I remove the use of FooItr::Ptr from Foo it compiles, so I assume it's circular dependency of FooItr using Foo::FooList and Foo using FooItr::Ptr that's the problem.Code:t.C: In instantiation of `FooItr<int>': t.C:29: instantiated from `Foo<int>' t.C:42: instantiated from here t.C:20: error: no type named `FooList' in `class Foo<int>'
EDIT: Sorry should have been more clear. I realise I can solve this with a "typedef template" (not sure of the proper term) i.e. FooItrPtr<T1>::Type instead of FooItr<T1>::Ptr, but I'm interested in what I'm doing wrong.
Thanks,
Stuart.



LinkBack URL
About LinkBacks


