diff --git a/CHANGELOG.md b/CHANGELOG.md index 1c53909e..97c5c7af 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ Version 149: * built-in r-value return values can't be assigned +* Tidy up ssl_stream special members -------------------------------------------------------------------------------- diff --git a/example/common/ssl_stream.hpp b/example/common/ssl_stream.hpp index ad21880f..0a498c02 100644 --- a/example/common/ssl_stream.hpp +++ b/example/common/ssl_stream.hpp @@ -35,11 +35,6 @@ template class ssl_stream : public boost::asio::ssl::stream_base { - // only works for boost::asio::ip::tcp::socket - // for now because of the move limitations - static_assert(std::is_same::value, - "NextLayer requirements not met"); - using stream_type = boost::asio::ssl::stream; std::unique_ptr p_; @@ -61,32 +56,25 @@ public: /// The type of the executor associated with the object. using executor_type = typename stream_type::executor_type; + template ssl_stream( - boost::asio::ip::tcp::socket socket, + Arg&& arg, boost::asio::ssl::context& ctx) : p_(new stream_type{ - socket.get_executor().context(), ctx}) + std::forward(arg), ctx}) , ctx_(&ctx) { - p_->next_layer() = std::move(socket); } ssl_stream(ssl_stream&& other) - : p_(new stream_type( - other.get_executor().context(), *other.ctx_)) + : p_(std::move(other.p_)) , ctx_(other.ctx_) { - using std::swap; - swap(p_, other.p_); } ssl_stream& operator=(ssl_stream&& other) { - std::unique_ptr p(new stream_type{ - other.get_executor().context(), other.ctx_}); - using std::swap; - swap(p_, p); - swap(p_, other.p_); + p_ = std::move(other.p_); ctx_ = other.ctx_; return *this; }