D
Daniel Pitts
I have a Vector template class (math vector), where the number of
dimensions is one of the template parameters.
template<typename component_t, int dimensions>
class Vector {...}
I'd like to specialize for Vector<*,3> to add
template<typename component_t>
Vector<component_t, 3> Vector<component_t, 3>::crossProduct(const
Vector<component_t, 3> &other) const {...}
Since cross product only makes sense with vectors that have dimension=3.
Is this possible? Basically, I want a compile time error if you call
crossProduct on a vector that isn't 3d.
Hmm, I think I figured out I can do it as a friend/external function,
but I'd like to try to do it as a member function. Is that possible?
template<typename component_t>
Vector<component_t, 3> crossProduct(const Vector<component_t, 3> &a,
const Vector<component_t, 3> &b) {...}
dimensions is one of the template parameters.
template<typename component_t, int dimensions>
class Vector {...}
I'd like to specialize for Vector<*,3> to add
template<typename component_t>
Vector<component_t, 3> Vector<component_t, 3>::crossProduct(const
Vector<component_t, 3> &other) const {...}
Since cross product only makes sense with vectors that have dimension=3.
Is this possible? Basically, I want a compile time error if you call
crossProduct on a vector that isn't 3d.
Hmm, I think I figured out I can do it as a friend/external function,
but I'd like to try to do it as a member function. Is that possible?
template<typename component_t>
Vector<component_t, 3> crossProduct(const Vector<component_t, 3> &a,
const Vector<component_t, 3> &b) {...}