1
0
mirror of https://github.com/mfontanini/libtins synced 2026-01-23 02:35:57 +01:00

Fix hash<IPv4/6Address> 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
This commit is contained in:
solvingj
2017-09-19 22:00:28 -04:00
committed by Matias Fontanini
parent e48f64daac
commit a7dd867503
4 changed files with 12 additions and 24 deletions

View File

@@ -35,6 +35,7 @@
#include <stdint.h>
#include "cxxstd.h"
#include "macros.h"
#include <functional>
namespace Tins {
/**
@@ -204,8 +205,11 @@ private:
namespace std {
template<>
TINS_API struct hash<Tins::IPv4Address> {
size_t operator()(const Tins::IPv4Address& addr) const;
struct hash<Tins::IPv4Address> {
size_t operator()(const Tins::IPv4Address& addr) const
{
return std::hash<std::uint32_t>()(addr);
}
};
} // std

View File

@@ -35,6 +35,7 @@
#include <stdint.h>
#include "cxxstd.h"
#include "macros.h"
#include <functional>
namespace Tins {
@@ -222,8 +223,11 @@ private:
namespace std {
template<>
TINS_API struct hash<Tins::IPv6Address> {
size_t operator()(const Tins::IPv6Address& addr) const;
struct hash<Tins::IPv6Address> {
size_t operator()(const Tins::IPv6Address& addr) const
{
return std::hash<string>()(addr.to_string());
}
};
} // std

View File

@@ -154,13 +154,3 @@ IPv4Address IPv4Address::operator&(const IPv4Address& mask) const {
}
} // Tins
#if TINS_IS_CXX11
namespace std {
size_t hash<Tins::IPv4Address>::operator()(const Tins::IPv4Address& addr) const {
return std::hash<uint32_t>()(addr);
}
} // std
#endif // TINS_IS_CXX11

View File

@@ -152,13 +152,3 @@ IPv6Address operator&(const IPv6Address& lhs, const IPv6Address& rhs) {
}
} // Tins
#if TINS_IS_CXX11
namespace std {
size_t hash<Tins::IPv6Address>::operator()(const Tins::IPv6Address& addr) const {
return std::hash<string>()(addr.to_string());
}
} // std
#endif // TINS_IS_CXX11