adding std::hash to fc::ip::endpoint
This commit is contained in:
parent
4bfaa4b962
commit
fa98cb6816
2 changed files with 21 additions and 0 deletions
|
|
@ -1,5 +1,6 @@
|
|||
#pragma once
|
||||
#include <fc/string.hpp>
|
||||
#include <fc/crypto/sha1.hpp>
|
||||
|
||||
namespace fc {
|
||||
|
||||
|
|
@ -53,3 +54,13 @@ namespace fc {
|
|||
void to_variant( const ip::address& var, variant& vo );
|
||||
void from_variant( const variant& var, ip::address& vo );
|
||||
}
|
||||
namespace std
|
||||
{
|
||||
template<typename T> struct hash;
|
||||
|
||||
template<>
|
||||
struct hash<fc::ip::endpoint>
|
||||
{
|
||||
size_t operator()( const fc::ip::endpoint& e )const;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -75,3 +75,13 @@ namespace fc { namespace ip {
|
|||
}
|
||||
|
||||
}
|
||||
namespace std
|
||||
{
|
||||
size_t hash<fc::ip::endpoint>::operator()( const fc::ip::endpoint& e )const
|
||||
{
|
||||
auto h = fc::sha1::hash( (char*)&e, sizeof(e) );
|
||||
size_t s;
|
||||
memcpy( (char*)&s, (char*)&h, sizeof(s) );
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue