R
Rune Allnor
Hi all.
I have an application where I need to do some computations on
vectors of numerical data. Specifically, the routine requires an
N-dimensional point and an N-dimensional vector as input.
The naive approach is to implement this as two instances
of std::vector<double>. However, I would like to include some
error-checking on the lengths of the vectors. I would at least
detect if the vectors are of different length (which would be
an error) and preferably specify by means of template
parameters exactly what the correct length should be.
It is no problem to do this at run-time and control parameters,
but this would imply a run-time overhead I would prefer
to avoid, if possible, and do all this book-keeping at
compile time instead.
Now, I would be surprised if there is a way to constrain the
sizes of the vectors at compile time, but I have to ask.
Assuming the answer is 'no', are there alternative approches
that achieve the goal?
Rune
I have an application where I need to do some computations on
vectors of numerical data. Specifically, the routine requires an
N-dimensional point and an N-dimensional vector as input.
The naive approach is to implement this as two instances
of std::vector<double>. However, I would like to include some
error-checking on the lengths of the vectors. I would at least
detect if the vectors are of different length (which would be
an error) and preferably specify by means of template
parameters exactly what the correct length should be.
It is no problem to do this at run-time and control parameters,
but this would imply a run-time overhead I would prefer
to avoid, if possible, and do all this book-keeping at
compile time instead.
Now, I would be surprised if there is a way to constrain the
sizes of the vectors at compile time, but I have to ask.
Assuming the answer is 'no', are there alternative approches
that achieve the goal?
Rune