我有一个重载的函数,我想传递它,包裹在 std::function 中。GCC4.6 没有找到“匹配函数”。虽然我确实在这里找到了一些问题,但答案并不像我希望的那样清楚。有人能告诉我为什么下面的代码不能扣除正确的重载以及如何(优雅地)解决它吗?
int test(const std::string&) {
return 0;
}
int test(const std::string*) {
return 0;
}
int main() {
std::function<int(const std::string&)> func = test;
return func();
}