I'm having this error when trying to instantiate a new object of a class. The code is:
using boost::asio::ip::tcp;
typedef boost::asio::io_service ioservice;
class cnx
{
public:
cnx(ioservice io);
private:
tcp::socket *s;
};
//constructor:
cnx::cnx(ioservice io)
{
this->s = new tcp::socket(io);
}
outside the cpp/h file of cnx, I try to instantiate as:
ioservice io;
cnx c(io);
or
cnx* c = new cnx(io);
and both result in this error message. What can be causing this?
As @tkausl said in the comments and also thanks to this answer, the problem was because boost::asio::io_service is not copyable. Changing the definition of the constructor to:
cnx(ioservice& io);
and calling it through:
ioservice io;
cnx c(std::ref(io));
solved the problem
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With