Is it safe to pass C ++ 11 std :: function to an inherited function that takes boost :: function

We have an outdated system that intensively uses boost :: function , now it decided to switch to more modern modern C ++ standards. Suppose we have such an inherited function:

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

Is it safe to directly pass 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 support standard lambda C ++ 11?

// will this also work?
someFunction([](int x)->void{
    //some implementation
});
+4
source share
1 answer

Yes it will work.

, . std::function boost::function. std::function boost::function.

- . .

: , .

+8

All Articles