读到这里,我觉得这段代码应该可以工作:
class Connection : public std::enable_shared_from_this<Connection>
{
public:
Connection(tcp::socket&& socket) : socket_(std::move(socket)) {}
private:
tcp::socket socket_;
};
但是编译器在构造函数中发出这个错误:
Call to implicitly-deleted copy constructor of 'tcp::socket' (aka'basic_stream_socket<boost::asio::ip::tcp>')
我也定义了BOOST_ASIO_HAS_MOVE
. 我使用 Xcode 4.6.3 并在编译器设置中定义了这个:
C++ Language dialect: GNU++11[-std=gnu++11]
C++ Standard Library: libc++(LLVM C++ standard library with C++11 support)