Binding to a function with optional parameters

2 Dec
2008
2 Dec
'08
7:39 a.m.
Is there a way to bind to a function with optional arguments? See my simple demo program below to see what I've tried: #include <boost/bind.hpp> #include <iostream> using namespace boost; using namespace std; int f(int x, int y = 0) { return x + y; } // Commented lines below don't compile. int main() { cout << bind(f, 1, 2)() << endl; // cout << bind(f, 1)() << endl; int (*p)(int, int) = f; cout << bind(p, 1, 2)() << endl; // int (*q)(int) = f; // cout << bind(q, 1)() << endl; return 0; } -- Yang Zhang http://www.mit.edu/~y_z/
6031
Age (days ago)
6031
Last active (days ago)
1 comments
2 participants
participants (2)
-
Steven Watanabe
-
Yang Zhang