[asio] how to handle "boost::asio::placeholders::error" in "boost::function"?

Hi all, I met a problem which can't be solved. Can any kind people help me? The code looks like the below: class transfor_data { public: void one_fun( const boost::system::error_code& e, connection conn ) { ... } void another_fun() { { //compile error because of the placeholder boost::function<void(void)> fun = boost::bind(&transfor_file_push::write_file, this, boost::asio::placeholders::error, conn); } { //fine without placeholder boost::system::error_code e; boost::function<void(void)> fun = boost::bind(&transfor_file_push::write_file, this, e, conn); } } }

{ //compile error because of the placeholder boost::function<void(void)> fun = boost::bind(&transfor_file_push::write_file, this, boost::asio::placeholders::error, conn); }
You have an error because the function signature you have indicated with boost::function is void yet you are binding two parameters. You probably want something like: boost::function< void<boost::system::error_code&, connection> fun HTH - michael -- ---------------------------------- Michael Caisse Object Modeling Designs www.objectmodelingdesigns.com

In fact I want to build a "Command" model. I need use "boost::function<void(void)>" to remove the relationship between general workflow and special function.
participants (3)
-
caoyawen
-
Michael Caisse
-
曹亚文