This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
RE: gcc template error?
- From: "Jason Mancini" <jayrusman at hotmail dot com>
- To: gcc at gcc dot gnu dot org
- Cc: shelly at interrasystems dot com
- Date: Wed, 22 Jun 2005 12:30:44 -0700
- Subject: RE: gcc template error?
- Bcc:
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;
}