Try
template <class NumType, size_t N>
void F(NumType (&array)[N]);
Pergunta
I have a function which is templated on its argument:
template <class Vector>
void F(Vector& vec);
I want to add a specialization of this function for numeric arrays. My attempt looks like this:
template <class NumType>
void F(NumType array[]);
I am having difficulty in calling the specialized function in the code. See below:
void main()
{
double a[] = {0.0, 1.0};
F(a); // This calls the Vector version of the function,
// with Vector = double [3], in my specific case.
}
If it helps, I do know beforehand that the function needs a length 3 array to work properly.
How do I fix my specialized function declaration so the NumType array version of the function is called?
Thanks
Solução
Try
template <class NumType, size_t N>
void F(NumType (&array)[N]);