Boost logo

Boost Users :

Subject: [Boost-users] storing a boost.thread in a boost shared ptr
From: Sean Farrow (sean.farrow_at_[hidden])
Date: 2011-03-21 03:45:31


Hi:
I'm trying to store a boost.thread in a boost::fusion::vector, and need to use a shared ptr, due to boost.thrad being non-copyable
I'm using Microsoft visual c++ 2010.

I get the following error:
     1>d:\devexpress\mdrlite\mdrlite\mdrlite\midiwidget.cpp(21): error C2664: 'boost::shared_ptr<T>::shared_ptr(boost::shared_ptr<T> &&)' : cannot convert parameter 1 from 'boost::_bi::bind_t<R,F,L>' to 'boost::shared_ptr<T> &&'
                 with
                 [
                     T=boost::thread
                 ]
                 and
                 [
                     R=size_t,
                     F=boost::_mfi::mf0<size_t,boost::asio::io_service>,
                     L=boost::_bi::list1<boost::_bi::value<boost::asio::io_service *>>
                 ]
                 and
                 [
                     T=boost::thread
                 ]
                 Reason: cannot convert from 'boost::_bi::bind_t<R,F,L>' to 'boost::shared_ptr<T>'
                 with
                 [
                     R=size_t,
                     F=boost::_mfi::mf0<size_t,boost::asio::io_service>,
                     L=boost::_bi::list1<boost::_bi::value<boost::asio::io_service *>>
                 ]
                 and
                 [
                     T=boost::thread
                 ]
                 No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
My boost thread is defined as:
boost::thread t(boost::bind(&boost::asio::io_service::run, io.get()));
and io is defined as:
boost::shared_ptr<boost::asio::io_service> io;
I'm obviously overlooking something, I just carn't work out what?
Any help appreciated.
Regards
Sean.



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net