specialization of template friends

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux