mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Sub in std::array for boost::array and beast::FixedArray
This commit is contained in:
@@ -147,7 +147,6 @@
|
|||||||
<ClInclude Include="..\..\beast\cxx14\memory.h" />
|
<ClInclude Include="..\..\beast\cxx14\memory.h" />
|
||||||
<ClInclude Include="..\..\beast\cxx14\type_traits.h" />
|
<ClInclude Include="..\..\beast\cxx14\type_traits.h" />
|
||||||
<ClInclude Include="..\..\beast\cxx14\utility.h" />
|
<ClInclude Include="..\..\beast\cxx14\utility.h" />
|
||||||
<ClInclude Include="..\..\beast\FixedArray.h" />
|
|
||||||
<ClInclude Include="..\..\beast\HeapBlock.h" />
|
<ClInclude Include="..\..\beast\HeapBlock.h" />
|
||||||
<ClInclude Include="..\..\beast\http\basic_message.h" />
|
<ClInclude Include="..\..\beast\http\basic_message.h" />
|
||||||
<ClInclude Include="..\..\beast\http\impl\http-parser\http_parser.h" />
|
<ClInclude Include="..\..\beast\http\impl\http-parser\http_parser.h" />
|
||||||
|
|||||||
@@ -735,9 +735,6 @@
|
|||||||
<ClInclude Include="..\..\beast\http\ParsedURL.h">
|
<ClInclude Include="..\..\beast\http\ParsedURL.h">
|
||||||
<Filter>beast\http</Filter>
|
<Filter>beast\http</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\beast\FixedArray.h">
|
|
||||||
<Filter>beast</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\..\beast\Crypto.h">
|
<ClInclude Include="..\..\beast\Crypto.h">
|
||||||
<Filter>beast</Filter>
|
<Filter>beast</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
|||||||
@@ -1,166 +0,0 @@
|
|||||||
//------------------------------------------------------------------------------
|
|
||||||
/*
|
|
||||||
This file is part of Beast: https://github.com/vinniefalco/Beast
|
|
||||||
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
|
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
|
||||||
copyright notice and this permission notice appear in all copies.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
||||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
||||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
*/
|
|
||||||
//==============================================================================
|
|
||||||
|
|
||||||
#ifndef BEAST_FIXEDARRAY_H_INCLUDED
|
|
||||||
#define BEAST_FIXEDARRAY_H_INCLUDED
|
|
||||||
|
|
||||||
#include "Config.h"
|
|
||||||
|
|
||||||
#include <cstddef>
|
|
||||||
#include <iterator>
|
|
||||||
#include <stdexcept>
|
|
||||||
|
|
||||||
namespace beast {
|
|
||||||
|
|
||||||
// Ideas from Boost
|
|
||||||
|
|
||||||
/** An array whose size is determined at compile-time.
|
|
||||||
The interface tries to follow std::vector as closely as possible within
|
|
||||||
the limitations of having a fixed size.
|
|
||||||
*/
|
|
||||||
template <class T, std::size_t N>
|
|
||||||
class FixedArray
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
T values [N];
|
|
||||||
|
|
||||||
typedef T value_type;
|
|
||||||
typedef T* iterator;
|
|
||||||
typedef T const* const_iterator;
|
|
||||||
typedef T& reference;
|
|
||||||
typedef T const& const_reference;
|
|
||||||
typedef std::size_t size_type;
|
|
||||||
typedef std::ptrdiff_t difference_type;
|
|
||||||
|
|
||||||
// iterators
|
|
||||||
iterator begin() { return values; }
|
|
||||||
const_iterator begin() const { return values; }
|
|
||||||
const_iterator cbegin() const { return values; }
|
|
||||||
iterator end() { return values+N; }
|
|
||||||
const_iterator end() const { return values+N; }
|
|
||||||
const_iterator cend() const { return values+N; }
|
|
||||||
|
|
||||||
typedef std::reverse_iterator <iterator> reverse_iterator;
|
|
||||||
typedef std::reverse_iterator <const_iterator> const_reverse_iterator;
|
|
||||||
|
|
||||||
reverse_iterator rbegin() { return reverse_iterator(end()); }
|
|
||||||
const_reverse_iterator rbegin() const { return const_reverse_iterator(end()); }
|
|
||||||
const_reverse_iterator crbegin() const { return const_reverse_iterator(end()); }
|
|
||||||
reverse_iterator rend() { return reverse_iterator(begin()); }
|
|
||||||
const_reverse_iterator rend() const { return const_reverse_iterator(begin()); }
|
|
||||||
const_reverse_iterator crend() const { return const_reverse_iterator(begin()); }
|
|
||||||
|
|
||||||
reference operator[](size_type i)
|
|
||||||
{
|
|
||||||
bassert (i < N);
|
|
||||||
return values[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
const_reference operator[](size_type i) const
|
|
||||||
{
|
|
||||||
bassert (i < N);
|
|
||||||
return values[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
reference at(size_type i) { rangecheck(i); return values[i]; }
|
|
||||||
const_reference at(size_type i) const { rangecheck(i); return values[i]; }
|
|
||||||
|
|
||||||
reference front() { return values[0]; }
|
|
||||||
reference back() { return values[N-1]; }
|
|
||||||
const_reference front () const { return values[0]; }
|
|
||||||
const_reference back() const { return values[N-1]; }
|
|
||||||
|
|
||||||
static size_type size() { return N; }
|
|
||||||
static bool empty() { return false; }
|
|
||||||
static size_type max_size() { return N; }
|
|
||||||
|
|
||||||
enum { static_size = N };
|
|
||||||
|
|
||||||
T const* data() const { return values; }
|
|
||||||
T* data() { return values; }
|
|
||||||
T* c_array() { return values; }
|
|
||||||
|
|
||||||
template <typename T2>
|
|
||||||
FixedArray<T,N>& operator= (FixedArray<T2,N> const& rhs)
|
|
||||||
{
|
|
||||||
std::copy (rhs.begin(), rhs.end(), begin());
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
void assign (T const& value) { fill (value); }
|
|
||||||
|
|
||||||
void fill (T const& value)
|
|
||||||
{
|
|
||||||
std::fill_n (begin(), size(), value);
|
|
||||||
}
|
|
||||||
|
|
||||||
void clear ()
|
|
||||||
{
|
|
||||||
fill (T ());
|
|
||||||
}
|
|
||||||
|
|
||||||
static void rangecheck (size_type i)
|
|
||||||
{
|
|
||||||
if (i >= size())
|
|
||||||
throw std::out_of_range ("FixedArray<>: index out of range");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
template <class T, std::size_t N>
|
|
||||||
bool operator== (FixedArray <T, N> const& lhs, FixedArray <T, N> const& rhs)
|
|
||||||
{
|
|
||||||
return std::equal (lhs.begin(), lhs.end(), rhs.begin());
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class T, std::size_t N>
|
|
||||||
bool operator!= (FixedArray <T, N> const& lhs, FixedArray <T, N> const& rhs)
|
|
||||||
{
|
|
||||||
return !(lhs==rhs);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class T, std::size_t N>
|
|
||||||
bool operator< (FixedArray <T, N> const& lhs, FixedArray <T, N> const& rhs)
|
|
||||||
{
|
|
||||||
return std::lexicographical_compare (
|
|
||||||
lhs.begin(), lhs.end(), rhs.begin(), rhs.end());
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class T, std::size_t N>
|
|
||||||
bool operator> (FixedArray <T, N> const& lhs, FixedArray <T, N> const& rhs)
|
|
||||||
{
|
|
||||||
return rhs<lhs;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class T, std::size_t N>
|
|
||||||
bool operator<= (FixedArray <T, N> const& lhs, FixedArray <T, N> const& rhs)
|
|
||||||
{
|
|
||||||
return !(rhs<lhs);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class T, std::size_t N>
|
|
||||||
bool operator>= (FixedArray <T, N> const& lhs, FixedArray <T, N> const& rhs)
|
|
||||||
{
|
|
||||||
return !(lhs<rhs);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -24,7 +24,6 @@
|
|||||||
#include "../utility/meta.h"
|
#include "../utility/meta.h"
|
||||||
|
|
||||||
#if BEAST_USE_BOOST_FEATURES
|
#if BEAST_USE_BOOST_FEATURES
|
||||||
#include <boost/array.hpp>
|
|
||||||
#include <boost/tuple/tuple.hpp>
|
#include <boost/tuple/tuple.hpp>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -155,17 +154,6 @@ struct is_contiguously_hashable <boost::tuple<T...>>
|
|||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// boost::array
|
|
||||||
template <class T, std::size_t N>
|
|
||||||
struct is_contiguously_hashable <boost::array<T, N>>
|
|
||||||
: public std::integral_constant <bool,
|
|
||||||
is_contiguously_hashable<T>::value &&
|
|
||||||
sizeof(T)*N == sizeof(boost::array<T, N>)>
|
|
||||||
{
|
|
||||||
};
|
|
||||||
|
|
||||||
static_assert (is_contiguously_hashable <boost::array<char, 3>>::value, "");
|
|
||||||
|
|
||||||
#endif // BEAST_USE_BOOST_FEATURES
|
#endif // BEAST_USE_BOOST_FEATURES
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
@@ -302,17 +290,6 @@ typename std::enable_if
|
|||||||
>::type
|
>::type
|
||||||
hash_append (Hasher& h, std::array<T, N> const& a) noexcept;
|
hash_append (Hasher& h, std::array<T, N> const& a) noexcept;
|
||||||
|
|
||||||
#if BEAST_USE_BOOST_FEATURES
|
|
||||||
|
|
||||||
template <class Hasher, class T, std::size_t N>
|
|
||||||
typename std::enable_if
|
|
||||||
<
|
|
||||||
!is_contiguously_hashable<boost::array<T, N>>::value
|
|
||||||
>::type
|
|
||||||
hash_append (Hasher& h, boost::array<T, N> const& a) noexcept;
|
|
||||||
|
|
||||||
#endif // BEAST_USE_BOOST_FEATURES
|
|
||||||
|
|
||||||
// std::tuple
|
// std::tuple
|
||||||
|
|
||||||
template <class Hasher>
|
template <class Hasher>
|
||||||
@@ -953,24 +930,6 @@ hash_append (Hasher& h, std::vector<T, Alloc> const& v) noexcept
|
|||||||
h.append (v.data(), v.size()*sizeof(T));
|
h.append (v.data(), v.size()*sizeof(T));
|
||||||
}
|
}
|
||||||
|
|
||||||
#if BEAST_USE_BOOST_FEATURES
|
|
||||||
|
|
||||||
// boost::array
|
|
||||||
|
|
||||||
template <class Hasher, class T, std::size_t N>
|
|
||||||
inline
|
|
||||||
std::enable_if_t
|
|
||||||
<
|
|
||||||
!is_contiguously_hashable<T>::value
|
|
||||||
>
|
|
||||||
hash_append (Hasher& h, boost::array<T, N> const& v) noexcept
|
|
||||||
{
|
|
||||||
for (auto const& t : v)
|
|
||||||
hash_append (h, t);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // BEAST_USE_BOOST_FEATURES
|
|
||||||
|
|
||||||
template <class Hasher, class T0, class T1, class ...T>
|
template <class Hasher, class T0, class T1, class ...T>
|
||||||
inline
|
inline
|
||||||
void
|
void
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
#define BEAST_ASIO_BASICS_FIXEDINPUTBUFFER_H_INCLUDED
|
#define BEAST_ASIO_BASICS_FIXEDINPUTBUFFER_H_INCLUDED
|
||||||
|
|
||||||
#include "../../../beast/asio/buffer_sequence.h"
|
#include "../../../beast/asio/buffer_sequence.h"
|
||||||
|
#include <array>
|
||||||
|
|
||||||
namespace beast {
|
namespace beast {
|
||||||
namespace asio {
|
namespace asio {
|
||||||
@@ -191,7 +192,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
boost::array <std::uint8_t, Bytes> m_storage;
|
std::array <std::uint8_t, Bytes> m_storage;
|
||||||
boost::asio::mutable_buffer m_buffer;
|
boost::asio::mutable_buffer m_buffer;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user