i wrote template function with 3 parameters, T - type of array, FUNC - function that return and get T as parameter, and N as size of array. I get compilation error telling pretty much nothing :"Failed to specialize function template".
template<typename T,T* (*FUNC)(T), int N>
void process(T array[])
{
for (int i=0;i<N;i++)
{
array[i] = FUNC(array[i]);
}
}
int main()
{
double a[] = { 1, 2, 3, 4 };
process<double, sin, 4>(a);
for (auto x : a)
std::cout << x << " "; // 0.841471 0.909297 0.14112 -0.756802
}
sinyour own function or a standard function? What is the exact error text?