boost::function














































boost::function



 Boost.function provides a class called boost::function to encapsulate function pointers. It is defined in boost/function.hpp.
 boost::function makes it possible to define a pointer to a function with a specific signature

Code:

#include <boost/function.hpp> #include <iostream> #include <cstdlib> #include <cstring> int main() { boost::function<int(const char*)> f = std::atoi; std::cout << f("2") << '\n'; f = std::strlen; std::cout << f("2") << '\n'; }




Comments