-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating

Boost C++ Application Development Cookbook
By :

We are continuing with the previous example, and now we want to pass a pointer to a function in our process_integers()
method. Shall we add an overload for just function pointers, or is there a more elegant way?
This recipe is continuing the previous one. You must read the previous recipe first.
Nothing needs to be done as boost::function<>
is also constructible from the function pointers:
void my_ints_function(int i); int main() { process_integers(&my_ints_function); }
A pointer to my_ints_function
will be stored inside the boost::function
class, and calls to boost::function
will be forwarded to the stored pointer.
The Boost.Function
library provides a good performance for pointers to functions, and it will not allocate memory on heap. Standard library std::function
is also effective in storing function pointers. Since Boost 1.58, the Boost.Function
library can store functions and...
Change the font size
Change margin width
Change background colour