Re: Can you specialize the Template operator==
3DCoderGuy <nobody@nospam.com> wrote:
I'm trying to specialize the operator== for my template, here is my
code
#define DOUBLE_EPSILON (1e-6)
#define FLOAT_EPSILON (1e-4f)
bool const operator==(const XYZPoint<T> &xyzTest) const
I assume this is a member function inside something like
template <typename T> class XYZPoint {...};
template<typename T>
bool const operator==(const XYZPoint<float> &xyzTest) const
This is not a specialization of the above, but an overload. The T here
is unrelated to the T which is the class' template parameter. Further,
this overload will never be selected in practice, because in any natural
invocation syntax, T is non-deducible (it doesn't appear anywhere in the
function signature).
Apparently, you want to specialize a member function of class template.
Such a specialization must go outside the class definition, and looks
like this:
template<>
bool const XYZPoint<float>::operator==(const XYZPoint<float>& xyzTest)
const;
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925