specialization of template friends
W_Guthrie
pontusmelke@gmail.com
Wed Nov 7 10:19:00 GMT 2007
Hi!
I have the following problem: I have written a Vector-class which looks
somewhat like this
template <int T> class Vector;
template <int T> double dot(const Vector<T>& u, const Vector<T>& v);
template<int T>
class Vector {
Vector& operator+=(const Vector& v);
...
friend double dot <>(const Vector<T>& u, const Vector<T>& v);
};
Now I want add a cross-product which only is a friend of Vector<3>, how do I
do this? I had one solution which looked like this:
template<int T>
class Vector {
Vector& operator+=(const Vector& v);
...
friend double dot <>(const Vector<T>& u, const Vector<T>& v);
friend Vector<3> cross(const Vector<T>& u, const Vector<T>& v);
};
But this only works if I compile with -O3 or explicitly make the function to
an inline function? Does anyone know why this is? How should one do this?
Please let me know!
/Woodie
--
View this message in context: http://www.nabble.com/specialization-of-template-friends-tf4763774.html#a13624507
Sent from the gcc - Help mailing list archive at Nabble.com.
More information about the Gcc-help
mailing list