[Function] Interest in boost::functions that take and return references to self-type?

Would there be interest in adding a feature to boost::function that allows a function to accept as input and return values of the same type as itself? I think this would be useful for implementing state machines. Something like: typedef boost::function< boost::function_self_type (event const&) > state_transition_fcn; state_transition_fcn initial_state (event const& e); state_transition_fcn second_state (event const& e); state_transition_fcn initial_state (event const& e) { if (/* some predicate on e*/) { // go to new state return &second_state; } else { // stay in old state return &initial_state; } } state_transition_fcn current_state = &initial_state; while (more_events) { current_state = current_state( next_event ); } -Tony Astolfi ps. Please point me in the right direction if such a thing already exists! Thanks!

ps. Please point me in the right direction if such a thing already exists! Thanks!
If state machines are what you're after have a look at Boost.Statechart http://www.boost.org/doc/libs/1_40_0/libs/statechart/doc/index.html or (soon to be reviewed) Boost.MSM in boost vault http://www.boostpro.com/vault/
participants (2)
-
Juraj Ivančić
-
Tony Astolfi