#include #include typedef boost::function1 HandlerType1; void registerCallback(HandlerType1 h) { int i = 45; // callback by passing the argument at callback time h(i); } void twoarg_callback(int i, int j) { printf("%d, %d\n", i, j); } void singlearg_callback(int i) { printf("%d\n", i); } int main() { // This line compiles okay HandlerType1 h1 = &singlearg_callback; h1(14); // This is fine too boost::function k = boost::bind(&twoarg_callback, 3, 4); k(); // This line compiles too boost::function i = &twoarg_callback; boost::bind(i, 3); // *** None of the following lines don't seem to work // boost::function j = boost::bind(&twoarg_callback, 3, _2); // boost::function j = boost::bind(&twoarg_callback, 3); // boost::function1 j = boost::bind(&twoarg_callback, 3); // boost::function1 j = boost::bind(&twoarg_callback, 3, _2); return 0; }