Template deduction reversion with function pointer
What have I done wrong and how can I fix it?
The way to fix that is to #include <cmath>
instead of using #include <math.h>
as mentioned in the reference documentation:
#include <cmath> // <<< official header to use.
#include <iostream>
template<typename T,typename T1>
T apply(T (*func)(T1), const T1 &val)
{
return func(val);
}
int main(void)
{
double val1 = 0.5, val2 = apply(ceil,val1);
std::cout << val1 << ' ' << val2<< std::endl;
}