diff --git a/src/Network/UdpServer.h b/src/Network/UdpServer.h index 7e4eb06d..a5151f70 100644 --- a/src/Network/UdpServer.h +++ b/src/Network/UdpServer.h @@ -11,7 +11,10 @@ #ifndef TOOLKIT_NETWORK_UDPSERVER_H #define TOOLKIT_NETWORK_UDPSERVER_H +#if __cplusplus >= 201703L +#include #include +#endif #include "Server.h" #include "Session.h" @@ -19,8 +22,17 @@ namespace toolkit { class UdpServer : public Server { public: +#if __cplusplus >= 201703L class PeerIdType : public std::array { +#else + class PeerIdType : public std::string { +#endif public: +#if __cplusplus < 201703L + PeerIdType() { + resize(18); + } +#endif bool operator==(const PeerIdType &that) const { return as(0) == that.as(0) && as(8) == that.as(8) && @@ -91,7 +103,11 @@ class UdpServer : public Server { private: struct PeerIdHash { +#if __cplusplus >= 201703L size_t operator()(const PeerIdType &v) const noexcept { return std::hash {}(std::string_view(v.data(), v.size())); } +#else + size_t operator()(const PeerIdType &v) const noexcept { return std::hash {}(v); } +#endif }; using SessionMapType = std::unordered_map;