Rella
Rella

Reputation: 66975

Shared_Ptr of socket creation - what is wrong?

So I try:

        boost::shared_ptr<tcp::socket> socket =
            boost::make_shared<tcp::socket>(io_service);

As described here. But It bring me an error:

Compiler tells me that it can not turn (

error C2664: 
boost::asio::basic_stream_socket<Protocol>::basic_stream_socket(
    boost::asio::io_­service &))
'boost::asio::io_service *const ' into 'boost::asio::io_service &'
\include\boost\smart_ptr\make_shared.hpp    

What shall I do?

Upvotes: 2

Views: 1373

Answers (1)

Sam Miller
Sam Miller

Reputation: 24174

You need to pass the io_service as a reference when using make_shared.

boost::shared_ptr<tcp::socket> socket =
            boost::make_shared<tcp::socket>(boost::ref(io_service));

Upvotes: 5

Related Questions