Is it safe to pass C++11 std::function to a legacy function that takes boost::function

Viewed 160

We have a legacy system that uses boost::function intensively, now it's decided to move to newer modern C++ standards. Suppose we have a legacy function like this:

void someFunction(boost::function<void(int)>);

Is it safe to directly pass in a C++11 function?

//calling site, new C++11 code
std::function<void(int)> func = [](int x){
    //some implementation
}
someFunction(func); //will this always work?

Does boost::function also handles standard C++11 lambda gracefully?

// will this also work?
someFunction([](int x)->void{
    //some implementation
});
1 Answers
Related