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?
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.