Peter Dimov wrote: > Aleksey Gurtovoy wrote: > > Consider the following snippet: > > > > void show_warning( message_dialog const&, user_message ); > > void post_command( boost::function<void()> ); > > > > int main() > > { > > boost::function<void( user_message )> f( > > bind( &post_command > > , ????( bind( &show_warning, message_dialog(), _1 ) ) > > // ^^^^ what goes here? > > "protect", in boost/bind/protect.hpp. Lambda has both "protect" and > "unlambda", either will work (I think). > > > ) > > ); > > }
I am afraid it's not that simple. Note that 'post_command' takes a _nullary_, not an unary function. To clarify the semantics of the above, I need to construct a bind expression which would allow the original code to become equivalent to the following: void post_show_warning_command( message_dialog const& a_dialog , user_message a_message ) { post_command( boost::bind( &show_warning , a_dialog , a_message ) ); } int main() { boost::function<void( user_message )> f( boost::bind( &post_show_warning_command , message_dialog() , _1 ) ); } Aleksey _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost