This is the mail archive of the gcc@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]

RE: gcc template error?


I suspect this line is the source of your problems:
  friend T<class Y>* func<Y, X>(T<X>* p);
Y isn't a template parameter here, but a (concrete?) class named "Y".
The below compiles with 3.4.3 anyways...
Regards,
-Jason


// Line 1 class A { public: A() { }; ~A() { }; };


class B { public: B(); B(const A& a) { }; ~B(); };


template <typename X, typename Y> class T;


template <typename X, typename Y>
T<X,Y>* func(T<X,Y>* p);


template <typename X, typename Y> class T { X* m_; public: T(X* x) : m_(x) { }; ~T() { }; friend T<X,Y>* func<X,Y>(T<X,Y>* p); };


template <typename X, typename Y> T<X,Y>* func(T<X,Y>* p) { return (new T<X,Y>(new X(*p->m_))); }


int main() { A* a = new A(); T<A,B>* p = new T<A,B>(a); T<A,B>* q = func<A, B>(p); return 0; }



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