From 5ad95e894231a094bf3951fc436bc8b32f9bbfc7 Mon Sep 17 00:00:00 2001 From: ghostyusheng Date: Thu, 6 Jun 2024 22:56:50 +0800 Subject: [PATCH] fix: add Boost V1.7 + compatibility build support --- include/crow/socket_adaptors.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/include/crow/socket_adaptors.h b/include/crow/socket_adaptors.h index 901117f97..a194588aa 100644 --- a/include/crow/socket_adaptors.h +++ b/include/crow/socket_adaptors.h @@ -4,6 +4,13 @@ #include #endif #include "crow/settings.h" + +#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 + namespace crow { using namespace boost; @@ -19,7 +26,7 @@ namespace crow boost::asio::io_service& get_io_service() { - return socket_.get_io_service(); + return GET_IO_SERVICE(socket_); } tcp::socket& raw_socket() @@ -96,7 +103,7 @@ namespace crow boost::asio::io_service& get_io_service() { - return raw_socket().get_io_service(); + return GET_IO_SERVICE(raw_socket()); } template