lundi 17 juin 2019

Placing boost socket into std::map

I was thinking that this would be straight forward but I must be missing something crucial, hence the error =O. I'm receiving the 'use of deleted function' error inside my source file.

Anyhow, I know my header file is correctly hooked up as it's been called properly throughout the source file, besides this line and the source code snippet is the only place that should require evaluation.

Header source code

using boost::asio::ip::tcp;
tcp::acceptor mAcceptor;
std::map<std::string, tcp::socket> mSockets;

Source file code

tcp::socket socket(ioService);
mAcceptor.accept(socket);
std::string myKey = "Socket"; // Didn't add actual key string creation
mSockets[myKey] = socket;

Error

error: Use of delete function 'boost::asio::basic_stream_socket& boost::asio::basic_stream_socket::operator{const boost::asio::basic_stream_socket&)' mSockets[myKey] = socket;

Goes on to say: Is implicitly declared as deleted because 'boost::asio::basic_stream_socket' declares a move constructor or move assignment operator class basic_stream_socket.

Aucun commentaire:

Enregistrer un commentaire