Skip to content

Commit

Permalink
Fix build issues due to std::hash missing
Browse files Browse the repository at this point in the history
  • Loading branch information
mfontanini committed May 1, 2017
1 parent 60b5f3e commit 3f2f643
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 6 deletions.
4 changes: 4 additions & 0 deletions include/tins/hw_address.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@
#include <string>
#include <cstring>
#include "cxxstd.h"
#if TINS_IS_CXX11
// std::hash
#include <memory>
#endif // TINS_IS_CXX11

namespace Tins {
namespace Internals {
Expand Down
4 changes: 1 addition & 3 deletions include/tins/ip_address.h
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,7 @@ namespace std {

template<>
struct hash<Tins::IPv4Address> {
size_t operator()(const Tins::IPv4Address& addr) const {
return std::hash<uint32_t>()(addr);
}
size_t operator()(const Tins::IPv4Address& addr) const;
};

} // std
Expand Down
4 changes: 1 addition & 3 deletions include/tins/ipv6_address.h
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,7 @@ namespace std {

template<>
struct hash<Tins::IPv6Address> {
size_t operator()(const Tins::IPv6Address& addr) const {
return std::hash<std::string>()(addr.to_string());
}
size_t operator()(const Tins::IPv6Address& addr) const;
};

} // std
Expand Down
10 changes: 10 additions & 0 deletions src/ip_address.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@
#include <sys/socket.h>
#include <arpa/inet.h>
#endif // _WIN32
#if TINS_IS_CXX11
// std::hash
#include <memory>
#endif // TINS_IS_CXX11
#include <stdexcept>
#include <sstream>
#include <iostream>
Expand All @@ -41,6 +45,7 @@
#include "address_range.h"
#include "exceptions.h"


using std::string;
using std::ostringstream;
using std::ostream;
Expand Down Expand Up @@ -150,3 +155,8 @@ IPv4Address IPv4Address::operator&(const IPv4Address& mask) const {
}

} // Tins

// Hash
size_t std::hash<Tins::IPv4Address>::operator()(const Tins::IPv4Address& addr) const {
return std::hash<uint32_t>()(addr);
}
9 changes: 9 additions & 0 deletions src/ipv6_address.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@
#include <ws2tcpip.h>
#include <mstcpip.h>
#endif
#if TINS_IS_CXX11
// std::hash
#include <memory>
#endif // TINS_IS_CXX11
#include <limits>
#include <sstream>
#include <iostream>
Expand Down Expand Up @@ -148,3 +152,8 @@ IPv6Address operator&(const IPv6Address& lhs, const IPv6Address& rhs) {
}

} // Tins

// Hash
size_t std::hash<Tins::IPv6Address>::operator()(const Tins::IPv6Address& addr) const {
return std::hash<string>()(addr.to_string());
}

0 comments on commit 3f2f643

Please sign in to comment.