4
的遗留函数是否安全?我们有一个遗留系统,它使用boost :: function,现在决定迁移到更新的现代C++标准。假设我们有这样的遗留函数:将C++ 11 std :: function传递给需要boost :: function
void someFunction(boost::function<void(int)>);
直接传递C++ 11函数是否安全?
//calling site, new C++11 code
std::function<void(int)> func = [](int x){
//some implementation
}
someFunction(func); //will this always work?
boost :: function是否也可以优雅地处理标准C++ 11 lambda?
// will this also work?
someFunction([](int x)->void{
//some implementation
});