Dep: Raise required boost versions to 1.73 on windows and 1.71 on linux and remove compatibility code for unsupported versions

# Conflicts:
#	dep/boost/CMakeLists.txt
This commit is contained in:
Shauren authored and Ovahlord committed 2022-02-20 20:27:35 +01:00
1 parent bbcd74d671
commit 5ad23e61e4
8 files changed
+12 -94

No files matched your search

+2 -2
View File
@@ -37,9 +37,9 @@ check_cxx_source_compiles("
if (WIN32) if (WIN32)
# On windows the requirements are higher according to the wiki. # On windows the requirements are higher according to the wiki.
set(BOOST_REQUIRED_VERSION 1.70) set(BOOST_REQUIRED_VERSION 1.73)
else() else()
set(BOOST_REQUIRED_VERSION 1.68) set(BOOST_REQUIRED_VERSION 1.71)
endif() endif()
if (STD_HAS_WORKING_WREGEX) if (STD_HAS_WORKING_WREGEX)
+2 -12
View File
@@ -20,24 +20,14 @@
#include <boost/asio/deadline_timer.hpp> #include <boost/asio/deadline_timer.hpp>
#if BOOST_VERSION >= 107000
#define BasicDeadlineTimerThirdTemplateArg , boost::asio::io_context::executor_type
#elif BOOST_VERSION >= 106600
#define BasicDeadlineTimerThirdTemplateArg
#else
#define BasicDeadlineTimerThirdTemplateArg , boost::asio::deadline_timer_service<boost::posix_time::ptime, boost::asio::time_traits<boost::posix_time::ptime>>
#endif
#define DeadlineTimerBase boost::asio::basic_deadline_timer<boost::posix_time::ptime, boost::asio::time_traits<boost::posix_time::ptime> BasicDeadlineTimerThirdTemplateArg>
namespace Trinity namespace Trinity
{ {
namespace Asio namespace Asio
{ {
class DeadlineTimer : public DeadlineTimerBase class DeadlineTimer : public boost::asio::basic_deadline_timer<boost::posix_time::ptime, boost::asio::time_traits<boost::posix_time::ptime>, boost::asio::io_context::executor_type>
{ {
public: public:
using DeadlineTimerBase::basic_deadline_timer; using basic_deadline_timer::basic_deadline_timer;
}; };
} }
} }
+4 -24
View File
@@ -18,18 +18,8 @@
#ifndef IoContext_h__ #ifndef IoContext_h__
#define IoContext_h__ #define IoContext_h__
#include <boost/version.hpp>
#if BOOST_VERSION >= 106600
#include <boost/asio/io_context.hpp> #include <boost/asio/io_context.hpp>
#include <boost/asio/post.hpp> #include <boost/asio/post.hpp>
#define IoContextBaseNamespace boost::asio
#define IoContextBase io_context
#else
#include <boost/asio/io_service.hpp>
#define IoContextBaseNamespace boost::asio
#define IoContextBase io_service
#endif
namespace Trinity namespace Trinity
{ {
@@ -41,38 +31,28 @@ namespace Trinity
IoContext() : _impl() { } IoContext() : _impl() { }
explicit IoContext(int concurrency_hint) : _impl(concurrency_hint) { } explicit IoContext(int concurrency_hint) : _impl(concurrency_hint) { }
operator IoContextBaseNamespace::IoContextBase&() { return _impl; } operator boost::asio::io_context&() { return _impl; }
operator IoContextBaseNamespace::IoContextBase const&() const { return _impl; } operator boost::asio::io_context const&() const { return _impl; }
std::size_t run() { return _impl.run(); } std::size_t run() { return _impl.run(); }
void stop() { _impl.stop(); } void stop() { _impl.stop(); }
#if BOOST_VERSION >= 106600
boost::asio::io_context::executor_type get_executor() noexcept { return _impl.get_executor(); } boost::asio::io_context::executor_type get_executor() noexcept { return _impl.get_executor(); }
#endif
private: private:
IoContextBaseNamespace::IoContextBase _impl; boost::asio::io_context _impl;
}; };
template<typename T> template<typename T>
inline decltype(auto) post(IoContextBaseNamespace::IoContextBase& ioContext, T&& t) inline decltype(auto) post(boost::asio::io_context& ioContext, T&& t)
{ {
#if BOOST_VERSION >= 106600
return boost::asio::post(ioContext, std::forward<T>(t)); return boost::asio::post(ioContext, std::forward<T>(t));
#else
return ioContext.post(std::forward<T>(t));
#endif
} }
template<typename T> template<typename T>
inline decltype(auto) get_io_context(T&& ioObject) inline decltype(auto) get_io_context(T&& ioObject)
{ {
#if BOOST_VERSION >= 106600
return ioObject.get_executor().context(); return ioObject.get_executor().context();
#else
return ioObject.get_io_service();
#endif
} }
} }
} }
-12
View File
@@ -25,21 +25,9 @@ namespace Trinity
{ {
namespace Net namespace Net
{ {
#if BOOST_VERSION >= 106600
using boost::asio::ip::make_address; using boost::asio::ip::make_address;
using boost::asio::ip::make_address_v4; using boost::asio::ip::make_address_v4;
inline uint32 address_to_uint(boost::asio::ip::address_v4 const& address) { return address.to_uint(); } inline uint32 address_to_uint(boost::asio::ip::address_v4 const& address) { return address.to_uint(); }
#else
inline boost::asio::ip::address make_address(char const* str) { return boost::asio::ip::address::from_string(str); }
inline boost::asio::ip::address make_address(char const* str, boost::system::error_code& ec) { return boost::asio::ip::address::from_string(str, ec); }
inline boost::asio::ip::address make_address(std::string const& str) { return boost::asio::ip::address::from_string(str); }
inline boost::asio::ip::address make_address(std::string const& str, boost::system::error_code& ec) { return boost::asio::ip::address::from_string(str, ec); }
inline boost::asio::ip::address_v4 make_address_v4(char const* str) { return boost::asio::ip::address_v4::from_string(str); }
inline boost::asio::ip::address_v4 make_address_v4(char const* str, boost::system::error_code& ec) { return boost::asio::ip::address_v4::from_string(str, ec); }
inline boost::asio::ip::address_v4 make_address_v4(std::string const& str) { return boost::asio::ip::address_v4::from_string(str); }
inline boost::asio::ip::address_v4 make_address_v4(std::string const& str, boost::system::error_code& ec) { return boost::asio::ip::address_v4::from_string(str, ec); }
inline uint32 address_to_uint(boost::asio::ip::address_v4 const& address) { return address.to_ulong(); }
#endif
} }
} }
-14
View File
@@ -20,11 +20,8 @@
#include "Define.h" #include "Define.h"
#include "IpAddress.h" #include "IpAddress.h"
#include <boost/version.hpp>
#if BOOST_VERSION >= 106600
#include <boost/asio/ip/network_v4.hpp> #include <boost/asio/ip/network_v4.hpp>
#include <boost/asio/ip/network_v6.hpp> #include <boost/asio/ip/network_v6.hpp>
#endif
namespace Trinity namespace Trinity
{ {
@@ -32,13 +29,9 @@ namespace Trinity
{ {
inline bool IsInNetwork(boost::asio::ip::address_v4 const& networkAddress, boost::asio::ip::address_v4 const& mask, boost::asio::ip::address_v4 const& clientAddress) inline bool IsInNetwork(boost::asio::ip::address_v4 const& networkAddress, boost::asio::ip::address_v4 const& mask, boost::asio::ip::address_v4 const& clientAddress)
{ {
#if BOOST_VERSION >= 106600
boost::asio::ip::network_v4 network = boost::asio::ip::make_network_v4(networkAddress, mask); boost::asio::ip::network_v4 network = boost::asio::ip::make_network_v4(networkAddress, mask);
boost::asio::ip::address_v4_range hosts = network.hosts(); boost::asio::ip::address_v4_range hosts = network.hosts();
return hosts.find(clientAddress) != hosts.end(); return hosts.find(clientAddress) != hosts.end();
#else
return (clientAddress.to_ulong() & mask.to_ulong()) == (networkAddress.to_ulong() & mask.to_ulong());
#endif
} }
inline boost::asio::ip::address_v4 GetDefaultNetmaskV4(boost::asio::ip::address_v4 const& networkAddress) inline boost::asio::ip::address_v4 GetDefaultNetmaskV4(boost::asio::ip::address_v4 const& networkAddress)
@@ -54,16 +47,9 @@ namespace Trinity
inline bool IsInNetwork(boost::asio::ip::address_v6 const& networkAddress, uint16 prefixLength, boost::asio::ip::address_v6 const& clientAddress) inline bool IsInNetwork(boost::asio::ip::address_v6 const& networkAddress, uint16 prefixLength, boost::asio::ip::address_v6 const& clientAddress)
{ {
#if BOOST_VERSION >= 106600
boost::asio::ip::network_v6 network = boost::asio::ip::make_network_v6(networkAddress, prefixLength); boost::asio::ip::network_v6 network = boost::asio::ip::make_network_v6(networkAddress, prefixLength);
boost::asio::ip::address_v6_range hosts = network.hosts(); boost::asio::ip::address_v6_range hosts = network.hosts();
return hosts.find(clientAddress) != hosts.end(); return hosts.find(clientAddress) != hosts.end();
#else
(void)networkAddress;
(void)prefixLength;
(void)clientAddress;
return false;
#endif
} }
} }
} }
-11
View File
@@ -38,23 +38,12 @@ namespace Trinity
Optional<boost::asio::ip::tcp::endpoint> Resolve(boost::asio::ip::tcp const& protocol, std::string const& host, std::string const& service) Optional<boost::asio::ip::tcp::endpoint> Resolve(boost::asio::ip::tcp const& protocol, std::string const& host, std::string const& service)
{ {
boost::system::error_code ec; boost::system::error_code ec;
#if BOOST_VERSION >= 106600
boost::asio::ip::resolver_base::flags flagsResolver = boost::asio::ip::resolver_base::all_matching; boost::asio::ip::resolver_base::flags flagsResolver = boost::asio::ip::resolver_base::all_matching;
boost::asio::ip::tcp::resolver::results_type results = _impl.resolve(protocol, host, service, flagsResolver, ec); boost::asio::ip::tcp::resolver::results_type results = _impl.resolve(protocol, host, service, flagsResolver, ec);
if (results.begin() == results.end() || ec) if (results.begin() == results.end() || ec)
return {}; return {};
return results.begin()->endpoint(); return results.begin()->endpoint();
#else
boost::asio::ip::resolver_query_base::flags flagsQuery = boost::asio::ip::tcp::resolver::query::all_matching;
boost::asio::ip::tcp::resolver::query query(std::move(protocol), std::move(host), std::move(service), flagsQuery);
boost::asio::ip::tcp::resolver::iterator itr = _impl.resolve(query, ec);
boost::asio::ip::tcp::resolver::iterator end;
if (itr == end || ec)
return {};
return itr->endpoint();
#endif
} }
private: private:
+3 -14
View File
@@ -19,11 +19,8 @@
#define Strand_h__ #define Strand_h__
#include "IoContext.h" #include "IoContext.h"
#include <boost/asio/strand.hpp>
#if BOOST_VERSION >= 106600
#include <boost/asio/bind_executor.hpp> #include <boost/asio/bind_executor.hpp>
#endif #include <boost/asio/strand.hpp>
namespace Trinity namespace Trinity
{ {
@@ -32,21 +29,13 @@ namespace Trinity
/** /**
Hack to make it possible to forward declare strand (which is a inner class) Hack to make it possible to forward declare strand (which is a inner class)
*/ */
class Strand : public IoContextBaseNamespace::IoContextBase::strand class Strand : public boost::asio::io_context::strand
{ {
public: public:
Strand(IoContext& ioContext) : IoContextBaseNamespace::IoContextBase::strand(ioContext) { } Strand(IoContext& ioContext) : boost::asio::io_context::strand(ioContext) { }
}; };
#if BOOST_VERSION >= 106600
using boost::asio::bind_executor; using boost::asio::bind_executor;
#else
template<typename T>
inline decltype(auto) bind_executor(Strand& strand, T&& t)
{
return strand.wrap(std::forward<T>(t));
}
#endif
} }
} }
+1 -5
View File
@@ -22,16 +22,12 @@
#include "IpAddress.h" #include "IpAddress.h"
#include "Log.h" #include "Log.h"
#include <boost/asio/ip/tcp.hpp> #include <boost/asio/ip/tcp.hpp>
#include <functional>
#include <atomic> #include <atomic>
#include <functional>
using boost::asio::ip::tcp; using boost::asio::ip::tcp;
#if BOOST_VERSION >= 106600
#define TRINITY_MAX_LISTEN_CONNECTIONS boost::asio::socket_base::max_listen_connections #define TRINITY_MAX_LISTEN_CONNECTIONS boost::asio::socket_base::max_listen_connections
#else
#define TRINITY_MAX_LISTEN_CONNECTIONS boost::asio::socket_base::max_connections
#endif
class AsyncAcceptor class AsyncAcceptor
{ {