second line compiles well, but third gives me an errors
int (* const f)() = ff;
cout << typeid(replace<int (*)(), int, char>::type).name() << endl;
cout << typeid(replace<f, int, char>::type).name() << endl;
test.cpp:3:25: error: the value of ‘f’ is not usable in a constant expression
test.cpp:1:15: note: ‘f’ was not declared ‘constexpr’
test.cpp:3:37: error: template argument 1 is invalid
A template argument can be a function pointer only if the parameter is a non-type parameter. But sadly C++11 does even not yet allow to use the full variety of constant expressions to compute a template argument. For a non-type pointer or reference, you are only allowed to pass the value of another template parameter or the directly obtained address of the function or object, without storing it first in a
const/constexprvariable.This limitation will most probably be lifted for next C++ revision.