
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!