chriskohlhoff / asio

Asio C++ Library
http://think-async.com/Asio
4.86k stars 1.21k forks source link

Error initializing tcp socket with boost::ref(io_context) #701

Open ghost opened 3 years ago

ghost commented 3 years ago

@kkumar45 commented on Jun 7, 2019, 7:02 AM UTC:

Initializing tcp::socket with boost::ref(io_context) results in compilation error. It looks like a regression in boost::asio.

It can be reproduced easily with below code.

`#include <boost/asio.hpp>

include <boost/core/ref.hpp>

int main() { boost::asio::io_context io_context; boost::asio::ip::tcp::socket socket(boost::ref(io_context)); return 0; } `

Error details : boost/asio/detail/io_object_impl.hpp:101:40: error: ‘const class boost::reference_wrapperboost::asio::io_context’ has no member named ‘get_executor’; did you mean ‘get_pointer’? implementationexecutor(context.get_executor(),



I have attached a patch, which works as a workaround for the issue. (file: boost/asio/detail/io_object_impl.hpp)

[![io_object_impl](https://user-images.githubusercontent.com/26009849/59086755-4de01280-8920-11e9-8c66-37411b7306df.JPG)](https://user-images.githubusercontent.com/26009849/59086755-4de01280-8920-11e9-8c66-37411b7306df.JPG)

*This issue was moved by [chriskohlhoff](https://github.com/chriskohlhoff) from [boostorg/asio#252](https://github.com/boostorg/asio/issues/252).*
ghost commented 3 years ago

@djarek commented on Jun 7, 2019, 12:45 PM UTC:

#227