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:
committed by
Matias Fontanini
parent
e48f64daac
commit
a7dd867503
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user