$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
From: Peter Dimov (pdimov_at_[hidden])
Date: 2006-06-08 05:39:37
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()> >.