network: (fixes #372) Remove std::unary_function
Remove `std::unary_function` usage from `Ipv*AddressHash`. Use std::hash instead of class Hash (in ns-3). This is because speed is more important than cryptographic robustness. Signed-off-by: Ameya Deshpande <ameyanrd@outlook.com>
This commit is contained in:
committed by
Tommaso Pecorella
parent
1d1c98ab6e
commit
705ad52930
@@ -422,7 +422,7 @@ Ipv4Address::GetLoopback (void)
|
||||
|
||||
size_t Ipv4AddressHash::operator() (Ipv4Address const &x) const
|
||||
{
|
||||
return x.Get ();
|
||||
return std::hash<uint32_t>()(x.Get ());
|
||||
}
|
||||
|
||||
std::ostream& operator<< (std::ostream& os, Ipv4Address const& address)
|
||||
|
||||
@@ -435,12 +435,15 @@ inline bool operator < (const Ipv4Address &a, const Ipv4Address &b)
|
||||
*
|
||||
* \brief Class providing an hash for IPv4 addresses
|
||||
*/
|
||||
class Ipv4AddressHash : public std::unary_function<Ipv4Address, size_t> {
|
||||
class Ipv4AddressHash {
|
||||
public:
|
||||
/**
|
||||
* Returns the hash of the address
|
||||
* \brief Returns the hash of an IPv4 address.
|
||||
* \param x the address
|
||||
* \return the hash
|
||||
*
|
||||
* This method uses std::hash rather than class Hash
|
||||
* as speed is more important than cryptographic robustness.
|
||||
*/
|
||||
size_t operator() (Ipv4Address const &x) const;
|
||||
};
|
||||
|
||||
@@ -697,11 +697,11 @@ inline bool operator != (const Ipv6Prefix& a, const Ipv6Prefix& b)
|
||||
* \class Ipv6AddressHash
|
||||
* \brief Hash function class for IPv6 addresses.
|
||||
*/
|
||||
class Ipv6AddressHash : public std::unary_function<Ipv6Address, size_t>
|
||||
class Ipv6AddressHash
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* \brief Unary operator to hash IPv6 address.
|
||||
* \brief Returns the hash of an IPv6 address.
|
||||
* \param x IPv6 address to hash
|
||||
* \returns the hash of the address
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user