Refactoring of container usage:

* New ripple container aliases use hardened_hash
* Use std::tuple instead of boost::tuple
* Use std unordered containers instead of boost
* Fix Destroyer for new containers
* Fix warning for fnv1a on 32-bit arch
* Validator fixes for new containers
This commit is contained in:
Howard Hinnant
2014-04-03 17:08:52 -04:00
committed by Vinnie Falco
parent 8f5b4a6c96
commit fdfcebd1cb
10 changed files with 175 additions and 338 deletions

View File

@@ -22,6 +22,7 @@
#include "IPAddressV4.h"
#include "IPAddressV6.h"
#include "../container/hash_append.h"
#include <cstdint>
#include <ios>
@@ -136,6 +137,18 @@ public:
return m_v6;
}
template <class Hasher>
friend
void
hash_append(Hasher& h, Address const& addr)
{
using beast::hash_append;
if (addr.is_v4 ())
hash_append(h, addr.to_v4 ());
else
hash_append(h, addr.to_v6 ());
}
/** Arithmetic comparison. */
/** @{ */
friend

View File

@@ -20,6 +20,8 @@
#ifndef BEAST_NET_IPADDRESSV4_H_INCLUDED
#define BEAST_NET_IPADDRESSV4_H_INCLUDED
#include "../container/hash_append.h"
#include <cstdint>
#include <ios>
#include <string>
@@ -178,6 +180,13 @@ OutputStream& operator<< (OutputStream& os, AddressV4 const& addr)
std::istream& operator>> (std::istream& is, AddressV4& addr);
}
template <>
struct is_contiguously_hashable<IP::AddressV4>
: public std::integral_constant<bool, sizeof(IP::AddressV4) == sizeof(std::uint32_t)>
{
};
}
//------------------------------------------------------------------------------

View File

@@ -71,6 +71,13 @@ bool is_public (AddressV6 const& addr);
//------------------------------------------------------------------------------
template <class Hasher>
void
hash_append(Hasher&, AddressV6 const&)
{
assert(false);
}
/** boost::hash support. */
inline std::size_t hash_value (AddressV6 const&)
{ assert(false); return 0; }

View File

@@ -21,6 +21,7 @@
#define BEAST_NET_IPENDPOINT_H_INCLUDED
#include "IPAddress.h"
#include "../container/hash_append.h"
#include <cstdint>
#include <ios>
@@ -91,6 +92,15 @@ public:
{ return ! (rhs > lhs); }
/** @} */
template <class Hasher>
friend
void
hash_append (Hasher& h, Endpoint const& endpoint)
{
using beast::hash_append;
hash_append(h, endpoint.m_addr, endpoint.m_port);
}
private:
Address m_addr;
Port m_port;