forked from boostorg/beast
Use new buffer traits, remove old unused traits
This commit is contained in:
1 parent
8f1faababd
commit
fa14af2696
15 files changed
+148
-199
No files matched your search
@@ -59,9 +59,8 @@ class buffers_cat_view<Bn...>::const_iterator
|
||||
"A minimum of two sequences are required");
|
||||
|
||||
detail::tuple<Bn...> const* bn_ = nullptr;
|
||||
detail::variant<typename
|
||||
detail::buffer_sequence_iterator<Bn>::type...,
|
||||
past_end> it_;
|
||||
detail::variant<
|
||||
buffers_iterator_type<Bn>..., past_end> it_;
|
||||
|
||||
friend class buffers_cat_view<Bn...>;
|
||||
|
||||
@@ -69,8 +68,8 @@ class buffers_cat_view<Bn...>::const_iterator
|
||||
using C = std::integral_constant<std::size_t, I>;
|
||||
|
||||
public:
|
||||
using value_type = typename
|
||||
detail::common_buffers_type<Bn...>::type;
|
||||
using value_type =
|
||||
typename buffers_cat_view<Bn...>::value_type;
|
||||
using pointer = value_type const*;
|
||||
using reference = value_type;
|
||||
using difference_type = std::ptrdiff_t;
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#ifndef BOOST_BEAST_IMPL_BUFFERS_PREFIX_HPP
|
||||
#define BOOST_BEAST_IMPL_BUFFERS_PREFIX_HPP
|
||||
|
||||
#include <boost/config/workaround.hpp>
|
||||
#include <algorithm>
|
||||
#include <cstdint>
|
||||
#include <iterator>
|
||||
@@ -30,12 +31,21 @@ class buffers_prefix_view<Buffers>::const_iterator
|
||||
iter_type it_;
|
||||
|
||||
public:
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, < 1910)
|
||||
using value_type = typename std::conditional<
|
||||
boost::is_convertible<typename
|
||||
std::iterator_traits<iter_type>::value_type,
|
||||
net::mutable_buffer>::value,
|
||||
net::mutable_buffer,
|
||||
net::const_buffer>::type;
|
||||
#else
|
||||
using value_type = buffers_type<Buffers>;
|
||||
#endif
|
||||
|
||||
BOOST_STATIC_ASSERT(std::is_same<
|
||||
typename const_iterator::value_type,
|
||||
typename buffers_prefix_view::value_type>::value);
|
||||
|
||||
using pointer = value_type const*;
|
||||
using reference = value_type;
|
||||
using difference_type = std::ptrdiff_t;
|
||||
@@ -61,7 +71,9 @@ public:
|
||||
reference
|
||||
operator*() const
|
||||
{
|
||||
return beast::buffers_prefix(remain_, *it_);
|
||||
value_type v(*it_);
|
||||
return { v.data(),
|
||||
remain_ < v.size() ? remain_ : v.size()};
|
||||
}
|
||||
|
||||
pointer
|
||||
@@ -70,7 +82,8 @@ public:
|
||||
const_iterator&
|
||||
operator++()
|
||||
{
|
||||
remain_ -= net::buffer_size(*it_++);
|
||||
value_type const v = *it_++;
|
||||
remain_ -= v.size();
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -78,14 +91,16 @@ public:
|
||||
operator++(int)
|
||||
{
|
||||
auto temp = *this;
|
||||
remain_ -= net::buffer_size(*it_++);
|
||||
value_type const v = *it_++;
|
||||
remain_ -= v.size();
|
||||
return temp;
|
||||
}
|
||||
|
||||
const_iterator&
|
||||
operator--()
|
||||
{
|
||||
remain_ += net::buffer_size(*--it_);
|
||||
value_type const v = *--it_;
|
||||
remain_ += v.size();
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -93,7 +108,8 @@ public:
|
||||
operator--(int)
|
||||
{
|
||||
auto temp = *this;
|
||||
remain_ += net::buffer_size(*--it_);
|
||||
value_type const v = *--it_;
|
||||
remain_ += v.size();
|
||||
return temp;
|
||||
}
|
||||
|
||||
@@ -130,8 +146,7 @@ setup(std::size_t size)
|
||||
auto const last = bs_.end();
|
||||
while(end_ != last)
|
||||
{
|
||||
auto const len =
|
||||
net::const_buffer(*end_++).size();
|
||||
auto const len = net::buffer_size(*end_++);
|
||||
if(len >= size)
|
||||
{
|
||||
size_ += size;
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#ifndef BOOST_BEAST_IMPL_BUFFERS_SUFFIX_HPP
|
||||
#define BOOST_BEAST_IMPL_BUFFERS_SUFFIX_HPP
|
||||
|
||||
#include <boost/beast/core/type_traits.hpp>
|
||||
#include <boost/beast/core/buffer_traits.hpp>
|
||||
#include <boost/type_traits.hpp>
|
||||
#include <algorithm>
|
||||
#include <cstdint>
|
||||
@@ -26,19 +26,22 @@ class buffers_suffix<Buffers>::const_iterator
|
||||
{
|
||||
friend class buffers_suffix<Buffers>;
|
||||
|
||||
using iter_type = typename
|
||||
detail::buffer_sequence_iterator<Buffers>::type;
|
||||
using iter_type = buffers_iterator_type<Buffers>;
|
||||
|
||||
iter_type it_;
|
||||
buffers_suffix const* b_ = nullptr;
|
||||
|
||||
public:
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, < 1910)
|
||||
using value_type = typename std::conditional<
|
||||
boost::is_convertible<typename
|
||||
std::iterator_traits<iter_type>::value_type,
|
||||
net::mutable_buffer>::value,
|
||||
net::mutable_buffer,
|
||||
net::const_buffer>::type;
|
||||
#else
|
||||
using value_type = buffers_type<Buffers>;
|
||||
#endif
|
||||
using pointer = value_type const*;
|
||||
using reference = value_type;
|
||||
using difference_type = std::ptrdiff_t;
|
||||
@@ -54,20 +57,7 @@ public:
|
||||
bool
|
||||
operator==(const_iterator const& other) const
|
||||
{
|
||||
return
|
||||
(b_ == nullptr) ?
|
||||
(
|
||||
other.b_ == nullptr ||
|
||||
other.it_ == net::buffer_sequence_end(other.b_->bs_)
|
||||
):(
|
||||
(other.b_ == nullptr) ?
|
||||
(
|
||||
it_ == net::buffer_sequence_end(b_->bs_)
|
||||
): (
|
||||
b_ == other.b_ &&
|
||||
it_ == other.it_
|
||||
)
|
||||
);
|
||||
return b_ == other.b_ && it_ == other.it_;
|
||||
}
|
||||
|
||||
bool
|
||||
@@ -118,8 +108,9 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
const_iterator(buffers_suffix const& b,
|
||||
iter_type it)
|
||||
const_iterator(
|
||||
buffers_suffix const& b,
|
||||
iter_type it)
|
||||
: it_(it)
|
||||
, b_(&b)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user