diff --git a/beast/container/hash_append.h b/beast/container/hash_append.h index 6f94c5c3f..fa5a73454 100644 --- a/beast/container/hash_append.h +++ b/beast/container/hash_append.h @@ -702,16 +702,6 @@ struct uhash } }; -struct call_hash_value -{ - template - std::size_t - operator()(T const& t) const noexcept - { - return hash_value(t); - } -}; - } // beast #endif diff --git a/beast/http/URL.h b/beast/http/URL.h index c8bdfb3d2..7b2b876ec 100644 --- a/beast/http/URL.h +++ b/beast/http/URL.h @@ -131,8 +131,6 @@ hash_append (Hasher& h, URL const& url) hash_append (h, url.toString()); } -extern std::size_t hash_value (beast::URL const& url); - } //------------------------------------------------------------------------------ @@ -143,7 +141,7 @@ template <> struct hash { std::size_t operator() (beast::URL const& v) const - { return beast::hash_value (v); } + { return v.toString().hash(); } }; } diff --git a/beast/http/impl/URL.cpp b/beast/http/impl/URL.cpp index d1e772ebc..1f6a9ebfd 100644 --- a/beast/http/impl/URL.cpp +++ b/beast/http/impl/URL.cpp @@ -164,14 +164,4 @@ std::ostream& operator<< (std::ostream &os, URL const& url) return os; } -//------------------------------------------------------------------------------ - -std::size_t hash_value (URL const& v) -{ - return std::size_t (v.toString().hash()); } - -} - - -// boost::hash support \ No newline at end of file diff --git a/beast/net/IPAddress.h b/beast/net/IPAddress.h index 41ce4d1fb..a9805c9bf 100644 --- a/beast/net/IPAddress.h +++ b/beast/net/IPAddress.h @@ -24,6 +24,8 @@ #include #include +#include + #include #include #include @@ -277,16 +279,6 @@ is_public (Address const& addr) //------------------------------------------------------------------------------ -/** boost::hash support. */ -inline -std::size_t -hash_value (Address const& addr) -{ - return (addr.is_v4 ()) - ? hash_value (addr.to_v4()) - : hash_value (addr.to_v6()); -} - /** Returns the address represented as a string. */ inline std::string to_string (Address const& addr) { @@ -337,7 +329,19 @@ struct hash std::size_t operator() (beast::IP::Address const& addr) const { - return hash_value (addr); + return beast::uhash<>{} (addr); + } +}; +} + +namespace boost { +template <> +struct hash +{ + std::size_t + operator() (beast::IP::Address const& addr) const + { + return beast::uhash<>{} (addr); } }; } diff --git a/beast/net/IPAddressV4.h b/beast/net/IPAddressV4.h index ebb3a9746..6f9f38049 100644 --- a/beast/net/IPAddressV4.h +++ b/beast/net/IPAddressV4.h @@ -23,6 +23,7 @@ #include #include +#include #include #include #include @@ -164,10 +165,6 @@ bool is_public (AddressV4 const& addr); //------------------------------------------------------------------------------ -/** boost::hash support. */ -inline std::size_t hash_value (AddressV4 const& addr) - { return addr.value; } - /** Returns the address represented as a string. */ std::string to_string (AddressV4 const& addr); @@ -197,7 +194,7 @@ template <> struct hash { std::size_t operator() (beast::IP::AddressV4 const& addr) const - { return hash_value (addr); } + { return addr.value; } }; } diff --git a/beast/net/IPAddressV6.h b/beast/net/IPAddressV6.h index 3d1f542cf..98d3377fd 100644 --- a/beast/net/IPAddressV6.h +++ b/beast/net/IPAddressV6.h @@ -22,6 +22,7 @@ #include #include +#include #include #include #include @@ -78,10 +79,6 @@ hash_append(Hasher&, AddressV6 const&) assert(false); } -/** boost::hash support. */ -inline std::size_t hash_value (AddressV6 const&) - { assert(false); return 0; } - /** Returns the address represented as a string. */ std::string to_string (AddressV6 const& addr); @@ -104,7 +101,7 @@ template <> struct hash { std::size_t operator() (beast::IP::AddressV6 const& addr) const - { return hash_value (addr); } + { assert(false); return 0; } }; } diff --git a/beast/net/IPEndpoint.h b/beast/net/IPEndpoint.h index 41a147f54..3d4cc731b 100644 --- a/beast/net/IPEndpoint.h +++ b/beast/net/IPEndpoint.h @@ -132,9 +132,6 @@ inline bool is_public (Endpoint const& endpoint) //------------------------------------------------------------------------------ -/** boost::hash support. */ -std::size_t hash_value (Endpoint const& endpoint); - /** Returns the endpoint represented as a string. */ inline std::string to_string (Endpoint const& endpoint) { return endpoint.to_string(); } @@ -161,7 +158,17 @@ template <> struct hash { std::size_t operator() (beast::IP::Endpoint const& endpoint) const - { return hash_value (endpoint); } + { return beast::uhash<>{} (endpoint); } +}; +} + +namespace boost { +/** boost::hash support. */ +template <> +struct hash +{ + std::size_t operator() (beast::IP::Endpoint const& endpoint) const + { return beast::uhash<>{} (endpoint); } }; } diff --git a/beast/net/impl/IPEndpoint.cpp b/beast/net/impl/IPEndpoint.cpp index 1f0749239..d4a4fe8b3 100644 --- a/beast/net/impl/IPEndpoint.cpp +++ b/beast/net/impl/IPEndpoint.cpp @@ -137,15 +137,6 @@ bool operator< (Endpoint const& lhs, Endpoint const& rhs) //------------------------------------------------------------------------------ -std::size_t hash_value (Endpoint const& endpoint) -{ - std::size_t seed (hash_value (endpoint.address ())); - // boost::hash_combine() - seed ^= (std::hash () (endpoint.port ())) - + 0x9e3779b9 + (seed << 6) + (seed >> 2); - return seed; -} - std::istream& operator>> (std::istream& is, Endpoint& endpoint) { // VFALCO TODO Support ipv6!