From a7dd867503b3774c8d1ae09c23b1d42e5bf0e7a9 Mon Sep 17 00:00:00 2001 From: solvingj Date: Tue, 19 Sep 2017 22:00:28 -0400 Subject: [PATCH] Fix hash build issues in VC * fixed compile failure due to macro * add functional to cxxstd.h to try to fix mac * clang bug identified, moving functional include to later * last step, move hash def to header * avoid allocation on hash * set ipv6 back to string hash --- include/tins/ip_address.h | 8 ++++++-- include/tins/ipv6_address.h | 8 ++++++-- src/ip_address.cpp | 10 ---------- src/ipv6_address.cpp | 10 ---------- 4 files changed, 12 insertions(+), 24 deletions(-) diff --git a/include/tins/ip_address.h b/include/tins/ip_address.h index e16387c..8b9b249 100644 --- a/include/tins/ip_address.h +++ b/include/tins/ip_address.h @@ -35,6 +35,7 @@ #include #include "cxxstd.h" #include "macros.h" +#include namespace Tins { /** @@ -204,8 +205,11 @@ private: namespace std { template<> -TINS_API struct hash { - size_t operator()(const Tins::IPv4Address& addr) const; +struct hash { + size_t operator()(const Tins::IPv4Address& addr) const + { + return std::hash()(addr); + } }; } // std diff --git a/include/tins/ipv6_address.h b/include/tins/ipv6_address.h index 454b9f7..aad0136 100644 --- a/include/tins/ipv6_address.h +++ b/include/tins/ipv6_address.h @@ -35,6 +35,7 @@ #include #include "cxxstd.h" #include "macros.h" +#include namespace Tins { @@ -222,8 +223,11 @@ private: namespace std { template<> -TINS_API struct hash { - size_t operator()(const Tins::IPv6Address& addr) const; +struct hash { + size_t operator()(const Tins::IPv6Address& addr) const + { + return std::hash()(addr.to_string()); + } }; } // std diff --git a/src/ip_address.cpp b/src/ip_address.cpp index d6d1c95..cca9af4 100644 --- a/src/ip_address.cpp +++ b/src/ip_address.cpp @@ -154,13 +154,3 @@ IPv4Address IPv4Address::operator&(const IPv4Address& mask) const { } } // Tins - -#if TINS_IS_CXX11 -namespace std { - -size_t hash::operator()(const Tins::IPv4Address& addr) const { - return std::hash()(addr); -} - -} // std -#endif // TINS_IS_CXX11 diff --git a/src/ipv6_address.cpp b/src/ipv6_address.cpp index d9e5e3f..36e12c2 100644 --- a/src/ipv6_address.cpp +++ b/src/ipv6_address.cpp @@ -152,13 +152,3 @@ IPv6Address operator&(const IPv6Address& lhs, const IPv6Address& rhs) { } } // Tins - -#if TINS_IS_CXX11 -namespace std { - -size_t hash::operator()(const Tins::IPv6Address& addr) const { - return std::hash()(addr.to_string()); -} - -} // std -#endif // TINS_IS_CXX11