Some years ago, I wrote a email client using Boost asio library.
There are a abstract class ICON with four subclasses.
POP3conN to flat POP3 communications
POP3conS to secure POP3 communications
SMTPconN to flat SMTP communications
SMTPconS to secure SMTP communications
ICON has a member
boost::asio::ip::tcp::socket socket_
and two virtual procedures, defined in echa subclass:
void SMTPconN::run() { socket_.get_io_service().run(); }
void SMTPconN::reset() { socket_.get_io_service().reset(); }
The application worked fine with boost_1_63_0. But when I try update to boost_1_70_0, the compiler (MS V Studio 2015) complains in both definitions:
class "boost::asio::ssl::stream<boost::asio::ip::tcp::socket>" has no member "get_io_service".
Because I want do the minimal change in what is a huge amount of code and complex logic: do is there some workaround to this missed method?
The docs state under Networking TS compatibility that you can use
get_context().context()
, which will get you aio_context
instance (which replacedio_service
somewhere around boost 1.64/1.65 IIRC).Both
get_io_service()
andget_io_context()
were previously in place to facilitate porting, but they have in the mean time also been deprecated and obsoleted.PS: Also see Get boost::asio::io_context from a boost::asio::ip::tcp::socket to exec a custom function which is eerily similar to your question but specifies a specific use-case.
The comments there have the decidedly better solution for that use-case:
Becomes
The subclasses: POP3conN and SMTPconN have a member:
Similarly, POP3conS and SMTPconS have a member:
The first argument of all constructors is a pointer to
io_service
. Some like:First change: in the abstract class IPCON has been added a new member:
wich is initialized in the constructor replacing the old reference to
io_service
:In the constructors of the subclasses has been added initialization to such member:
Second change: all occurences of
Can be replaced by
The problematic expressions
appears now like this:
It seems that the functionality of the old
io_service
has been replaced by the newio_context
.