我想使用一个库 (https://github.com/onlinecity/cpp-smpp),它基于 boost 1.41。但是在我们的项目中,我们使用的是 1.72。
那里有一个从 TCP 套接字 (socket->get_io_service()
here) 获取 io_service 的代码。然后这个对象在以下部分代码中使用:
deadline_timer timer(ioService);
和
ioService.run_one();
ioService.reset();
但是 get_io_service()
已从 boost 1.70+ 中删除。在这种情况下,我应该使用哪些函数和对象而不是那些函数和对象?
更新
还有一个问题 (Alternative to deprecated get_io_service()) 与我的相似,但该问题的答案在这个场景中不起作用。
答案 0 :(得分:0)
看看这个提交:https://github.com/mavlink/mavros/commit/3da41d770ca0e021f597bef30ffe6fcefe3e6959
它定义了一个宏
#if BOOST_VERSION >= 107000
#define GET_IO_SERVICE(s) ((boost::asio::io_context&)(s).get_executor().context())
#else
#define GET_IO_SERVICE(s) ((s).get_io_service())
#endif
并替换调用
socket.get_io_service()
与
GET_IO_SERVICE(socket)