Passing a unique_ptr link to boost :: bind?

I am on CentOS 6.6 (gcc 4.4.7) and developing with Boost.Asio (1.41). I would like io_service to call a member function run()in a manger object mat startup. The code I'm trying to compile looks like this:

#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 places the fit in a statement boost::bindthat includes:

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

What do I want to do here?

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

Clarification:

, m io.run(). m, io.run(). , m - io. ++ .

+4
1

++ - 14 -, - . shared_ptr, std::bind :

std::shared_ptr<manager> m;
m = std::make_shared<manager>();
io.post(std::bind(&manager::run, std::move(m)));

std::move , , m , .

+3

All Articles