【发布时间】:2011-12-14 08:57:48
【问题描述】:
第二行编译得很好,但第三行给我一个错误
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
【问题讨论】:
标签: c++ templates function parameters