From 3f2f6438fd92ef0ef97b278a53a435ed45bcf83f Mon Sep 17 00:00:00 2001 From: Matias Fontanini Date: Sun, 30 Apr 2017 19:55:23 -0700 Subject: [PATCH] Fix build issues due to std::hash missing --- include/tins/hw_address.h | 4 ++++ include/tins/ip_address.h | 4 +--- include/tins/ipv6_address.h | 4 +--- src/ip_address.cpp | 10 ++++++++++ src/ipv6_address.cpp | 9 +++++++++ 5 files changed, 25 insertions(+), 6 deletions(-) diff --git a/include/tins/hw_address.h b/include/tins/hw_address.h index 853822a..c0a24f7 100644 --- a/include/tins/hw_address.h +++ b/include/tins/hw_address.h @@ -35,6 +35,10 @@ #include #include #include "cxxstd.h" +#if TINS_IS_CXX11 + // std::hash + #include +#endif // TINS_IS_CXX11 namespace Tins { namespace Internals { diff --git a/include/tins/ip_address.h b/include/tins/ip_address.h index bfbcb6c..6e5f9c5 100644 --- a/include/tins/ip_address.h +++ b/include/tins/ip_address.h @@ -205,9 +205,7 @@ namespace std { template<> struct hash { - size_t operator()(const Tins::IPv4Address& addr) const { - return std::hash()(addr); - } + size_t operator()(const Tins::IPv4Address& addr) const; }; } // std diff --git a/include/tins/ipv6_address.h b/include/tins/ipv6_address.h index fcec9b3..6013635 100644 --- a/include/tins/ipv6_address.h +++ b/include/tins/ipv6_address.h @@ -223,9 +223,7 @@ namespace std { template<> struct hash { - size_t operator()(const Tins::IPv6Address& addr) const { - return std::hash()(addr.to_string()); - } + size_t operator()(const Tins::IPv6Address& addr) const; }; } // std diff --git a/src/ip_address.cpp b/src/ip_address.cpp index 740ab4c..fa35b2c 100644 --- a/src/ip_address.cpp +++ b/src/ip_address.cpp @@ -33,6 +33,10 @@ #include #include #endif // _WIN32 +#if TINS_IS_CXX11 + // std::hash + #include +#endif // TINS_IS_CXX11 #include #include #include @@ -41,6 +45,7 @@ #include "address_range.h" #include "exceptions.h" + using std::string; using std::ostringstream; using std::ostream; @@ -150,3 +155,8 @@ IPv4Address IPv4Address::operator&(const IPv4Address& mask) const { } } // Tins + +// Hash +size_t std::hash::operator()(const Tins::IPv4Address& addr) const { + return std::hash()(addr); +} diff --git a/src/ipv6_address.cpp b/src/ipv6_address.cpp index dfb7291..31a2474 100644 --- a/src/ipv6_address.cpp +++ b/src/ipv6_address.cpp @@ -37,6 +37,10 @@ #include #include #endif +#if TINS_IS_CXX11 + // std::hash + #include +#endif // TINS_IS_CXX11 #include #include #include @@ -148,3 +152,8 @@ IPv6Address operator&(const IPv6Address& lhs, const IPv6Address& rhs) { } } // Tins + +// Hash +size_t std::hash::operator()(const Tins::IPv6Address& addr) const { + return std::hash()(addr.to_string()); +}