1

Asio v1.20 standalone library server example shows how asio::ssl::stream is moved from the server class to the session class. When I try to compile the example, it throws me an error:

/home/user/tmp/tmp.ZxZvgK7sGZ/main.cpp: In constructor ‘session::session(asio::ssl::stream<asio::basic_stream_socket<asio::ip::tcp> >)’:
/home/user/tmp/tmp.ZxZvgK7sGZ/main.cpp:23:34: error: use of deleted function ‘asio::ssl::stream<asio::basic_stream_socket<asio::ip::tcp> >::stream(const asio::ssl::stream<asio::basic_stream_socket<asio::ip::tcp> >&)’
   23 |       : socket_(std::move(socket))
      |                                  ^
In file included from /usr/include/asio/ssl.hpp:22,
                 from /home/user/tmp/tmp.ZxZvgK7sGZ/main.cpp:15:
/usr/include/asio/ssl/stream.hpp:63:7: note: ‘asio::ssl::stream<asio::basic_stream_socket<asio::ip::tcp> >::stream(const asio::ssl::stream<asio::basic_stream_socket<asio::ip::tcp> >&)’ is implicitly deleted because the default definition would be ill-formed:
   63 | class stream :
      |       ^~~~~~
/usr/include/asio/ssl/stream.hpp:63:7: error: ‘asio::detail::noncopyable::noncopyable(const asio::detail::noncopyable&)’ is private within this context

I understand that I can't move my asio::ssl::stream because it is noncopyable, or am I missing something? How to make the example above compile?

I tried to use Asio standalone library with ASIO_HAS_MOVE as well.

Compiler:

$ g++ --version
g++ (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0

PROBLEM & SOLUTION

I installed the Asio library as a Debian package libasio-dev for which I didn't check the version. It is v1.18. I installed it from source now and it works, as @dewaffled pointed out.

Drejc
  • 491
  • 6
  • 21
  • 1
    [should be](https://github.com/chriskohlhoff/asio/blob/f70f65ae54351c209c3a24704624144bfe8e70a3/asio/include/asio/ssl/stream.hpp#L120) movable. you should probably check `/usr/include/asio/ssl/stream.hpp` you have, maybe it is just outdated library version. – dewaffled Jan 25 '22 at 12:41
  • I see where I did my mistake. I installed Asio library as an [Ubuntu package](https://zoomadmin.com/HowToInstall/UbuntuPackage/libasio-dev) `libasio-dev` for which I didn't check the version. It is [v1.18](https://packages.debian.org/sid/libasio-dev). I installed it from the source now and it works. – Drejc Jan 25 '22 at 15:08

0 Answers0