lundi 2 mars 2015

Passing a unique_ptr reference to boost::bind?


I'm on CentOS 6.6 (gcc 4.4.7) and developing with Boost.Asio (1.41). I'd like io_service to call member function run() in manger object m when it starts. The code I'm trying to compile looks like:



#include <memory>
#include <boost/asio.hpp>
#include <boost/bind.hpp>

boost::asio::io_service io;
std::unique_ptr<manager> m;
m = std::make_unique<manager>;
io.post(boost::bind(&manager::run, &m));


gcc pitches a fit on the boost::bind statement, which includes:



/usr/include/boost/bind/mem_fn_template.hpp:40: error: pointer to
member type ‘void (manager::)()’ incompatible with object type
‘std::unique_ptr<manager, std::default_delete<manager> >’


What do I want to be doing here?


The manager object will only know about timers; a separate object that knows about io_service will get added to its constructor later. But the idea is that manager::run() will create an initial set of timers to bootstrap the system.




Aucun commentaire:

Enregistrer un commentaire