
8 Jun
2006
8 Jun
'06
9:39 a.m.
Dean Michael Berris wrote:
//set up a registry dispatch::dispatcher<void (), int> callbacks;
// register a nullary free function f to index 0 callbacks[0] = f;
// bind arguments to a single argument function p to index 1 callbacks[1] = boost::bind(p, 1);
// get user input then execute appropriate callback int i; cin >> i; callbacks[i]();
This can be done with map< int, function<void()> >.