I have a Vector class which has a template of <unsigned int Dim>
, eg. I can do Vector<2>
for a vector in 2-dimensional space, Vector<4>
for 4-dimensional, etc. I want to add some methods to the class if Dim == specific value
, for instance CrossProduct
for Vector<3>
, or x,y,z,w
getters for a vector of sufficient dimension. If used with a Vector of incorrect dimensions, I would hope to get a compile error.
I have looked around quite a lot, one of the things that I believe are close enough is std::enable_if
, however, I have no clue how to use it for my particular case (where the condition is either Dim == x
, or Dim > x
).
Is this the right way, or is there a completely different way I should do this?
I am using C++17, by the way.