mirror of
https://github.com/boostorg/beast.git
synced 2025-07-31 13:27:33 +02:00
Tidy up some buffer sequence iterators
This commit is contained in:
@@ -2,6 +2,7 @@ Version 201
|
|||||||
|
|
||||||
* Decay bound arguments in handler wrapper parameters
|
* Decay bound arguments in handler wrapper parameters
|
||||||
* Add bind_back_handler
|
* Add bind_back_handler
|
||||||
|
* Tidy up default-constructed iterators
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@@ -39,9 +39,9 @@ class buffers_prefix_view
|
|||||||
buffers_iterator_type<BufferSequence>;
|
buffers_iterator_type<BufferSequence>;
|
||||||
|
|
||||||
BufferSequence bs_;
|
BufferSequence bs_;
|
||||||
std::size_t size_;
|
std::size_t size_ = 0;
|
||||||
std::size_t remain_;
|
std::size_t remain_ = 0;
|
||||||
iter_type end_;
|
iter_type end_{};
|
||||||
|
|
||||||
void
|
void
|
||||||
setup(std::size_t size);
|
setup(std::size_t size);
|
||||||
|
@@ -56,7 +56,7 @@ class buffers_suffix
|
|||||||
buffers_iterator_type<BufferSequence>;
|
buffers_iterator_type<BufferSequence>;
|
||||||
|
|
||||||
BufferSequence bs_;
|
BufferSequence bs_;
|
||||||
iter_type begin_;
|
iter_type begin_{};
|
||||||
std::size_t skip_ = 0;
|
std::size_t skip_ = 0;
|
||||||
|
|
||||||
template<class Deduced>
|
template<class Deduced>
|
||||||
@@ -124,7 +124,7 @@ public:
|
|||||||
explicit
|
explicit
|
||||||
buffers_suffix(boost::in_place_init_t, Args&&... args);
|
buffers_suffix(boost::in_place_init_t, Args&&... args);
|
||||||
|
|
||||||
/// Assignment
|
/// Copy Assignment
|
||||||
buffers_suffix& operator=(buffers_suffix const&);
|
buffers_suffix& operator=(buffers_suffix const&);
|
||||||
|
|
||||||
/// Get a bidirectional iterator to the first element.
|
/// Get a bidirectional iterator to the first element.
|
||||||
|
@@ -37,7 +37,7 @@ public:
|
|||||||
using iter_type =
|
using iter_type =
|
||||||
buffers_iterator_type<BufferSequence>;
|
buffers_iterator_type<BufferSequence>;
|
||||||
|
|
||||||
iter_type it_;
|
iter_type it_{};
|
||||||
buffers_range_adaptor const* b_ = nullptr;
|
buffers_range_adaptor const* b_ = nullptr;
|
||||||
|
|
||||||
const_iterator(
|
const_iterator(
|
||||||
|
@@ -97,7 +97,7 @@ class buffers_cat_view<Bn...>::const_iterator
|
|||||||
|
|
||||||
detail::tuple<Bn...> const* bn_ = nullptr;
|
detail::tuple<Bn...> const* bn_ = nullptr;
|
||||||
detail::variant<
|
detail::variant<
|
||||||
buffers_iterator_type<Bn>..., past_end> it_;
|
buffers_iterator_type<Bn>..., past_end> it_{};
|
||||||
|
|
||||||
friend class buffers_cat_view<Bn...>;
|
friend class buffers_cat_view<Bn...>;
|
||||||
|
|
||||||
@@ -105,8 +105,8 @@ class buffers_cat_view<Bn...>::const_iterator
|
|||||||
using C = std::integral_constant<std::size_t, I>;
|
using C = std::integral_constant<std::size_t, I>;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
using value_type =
|
using value_type = typename
|
||||||
typename buffers_cat_view<Bn...>::value_type;
|
buffers_cat_view<Bn...>::value_type;
|
||||||
using pointer = value_type const*;
|
using pointer = value_type const*;
|
||||||
using reference = value_type;
|
using reference = value_type;
|
||||||
using difference_type = std::ptrdiff_t;
|
using difference_type = std::ptrdiff_t;
|
||||||
@@ -115,7 +115,8 @@ public:
|
|||||||
|
|
||||||
const_iterator() = default;
|
const_iterator() = default;
|
||||||
const_iterator(const_iterator const& other) = default;
|
const_iterator(const_iterator const& other) = default;
|
||||||
const_iterator& operator=(const_iterator const& other) = default;
|
const_iterator& operator=(
|
||||||
|
const_iterator const& other) = default;
|
||||||
|
|
||||||
bool
|
bool
|
||||||
operator==(const_iterator const& other) const;
|
operator==(const_iterator const& other) const;
|
||||||
@@ -146,7 +147,12 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
const_iterator(
|
const_iterator(
|
||||||
detail::tuple<Bn...> const& bn, bool at_end);
|
detail::tuple<Bn...> const& bn,
|
||||||
|
std::true_type);
|
||||||
|
|
||||||
|
const_iterator(
|
||||||
|
detail::tuple<Bn...> const& bn,
|
||||||
|
std::false_type);
|
||||||
|
|
||||||
struct dereference
|
struct dereference
|
||||||
{
|
{
|
||||||
@@ -308,10 +314,21 @@ template<class... Bn>
|
|||||||
buffers_cat_view<Bn...>::
|
buffers_cat_view<Bn...>::
|
||||||
const_iterator::
|
const_iterator::
|
||||||
const_iterator(
|
const_iterator(
|
||||||
detail::tuple<Bn...> const& bn, bool at_end)
|
detail::tuple<Bn...> const& bn,
|
||||||
|
std::true_type)
|
||||||
: bn_(&bn)
|
: bn_(&bn)
|
||||||
{
|
{
|
||||||
if(! at_end)
|
// one past the end
|
||||||
|
it_.template emplace<sizeof...(Bn)+1>();
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class... Bn>
|
||||||
|
buffers_cat_view<Bn...>::
|
||||||
|
const_iterator::
|
||||||
|
const_iterator(
|
||||||
|
detail::tuple<Bn...> const& bn,
|
||||||
|
std::false_type)
|
||||||
|
: bn_(&bn)
|
||||||
{
|
{
|
||||||
it_.template emplace<1>(
|
it_.template emplace<1>(
|
||||||
net::buffer_sequence_begin(
|
net::buffer_sequence_begin(
|
||||||
@@ -319,11 +336,6 @@ const_iterator(
|
|||||||
increment{*this}.next(
|
increment{*this}.next(
|
||||||
mp11::mp_size_t<1>{});
|
mp11::mp_size_t<1>{});
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
it_.template emplace<sizeof...(Bn)+1>();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class... Bn>
|
template<class... Bn>
|
||||||
bool
|
bool
|
||||||
@@ -414,7 +426,7 @@ auto
|
|||||||
buffers_cat_view<Bn...>::begin() const ->
|
buffers_cat_view<Bn...>::begin() const ->
|
||||||
const_iterator
|
const_iterator
|
||||||
{
|
{
|
||||||
return const_iterator{bn_, false};
|
return const_iterator{bn_, std::false_type{}};
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class... Bn>
|
template<class... Bn>
|
||||||
@@ -422,7 +434,7 @@ auto
|
|||||||
buffers_cat_view<Bn...>::end() const->
|
buffers_cat_view<Bn...>::end() const->
|
||||||
const_iterator
|
const_iterator
|
||||||
{
|
{
|
||||||
return const_iterator{bn_, true};
|
return const_iterator{bn_, std::true_type{}};
|
||||||
}
|
}
|
||||||
|
|
||||||
} // beast
|
} // beast
|
||||||
|
@@ -28,7 +28,7 @@ class buffers_prefix_view<Buffers>::const_iterator
|
|||||||
|
|
||||||
buffers_prefix_view const* b_ = nullptr;
|
buffers_prefix_view const* b_ = nullptr;
|
||||||
std::size_t remain_ = 0;
|
std::size_t remain_ = 0;
|
||||||
iter_type it_;
|
iter_type it_{};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
#if BOOST_WORKAROUND(BOOST_MSVC, < 1910)
|
#if BOOST_WORKAROUND(BOOST_MSVC, < 1910)
|
||||||
@@ -53,8 +53,10 @@ public:
|
|||||||
std::bidirectional_iterator_tag;
|
std::bidirectional_iterator_tag;
|
||||||
|
|
||||||
const_iterator() = default;
|
const_iterator() = default;
|
||||||
const_iterator(const_iterator const& other) = default;
|
const_iterator(
|
||||||
const_iterator& operator=(const_iterator const& other) = default;
|
const_iterator const& other) = default;
|
||||||
|
const_iterator& operator=(
|
||||||
|
const_iterator const& other) = default;
|
||||||
|
|
||||||
bool
|
bool
|
||||||
operator==(const_iterator const& other) const
|
operator==(const_iterator const& other) const
|
||||||
@@ -72,8 +74,9 @@ public:
|
|||||||
operator*() const
|
operator*() const
|
||||||
{
|
{
|
||||||
value_type v(*it_);
|
value_type v(*it_);
|
||||||
return { v.data(),
|
if(remain_ < v.size())
|
||||||
remain_ < v.size() ? remain_ : v.size()};
|
return {v.data(), remain_};
|
||||||
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
pointer
|
pointer
|
||||||
|
@@ -28,7 +28,7 @@ class buffers_suffix<Buffers>::const_iterator
|
|||||||
|
|
||||||
using iter_type = buffers_iterator_type<Buffers>;
|
using iter_type = buffers_iterator_type<Buffers>;
|
||||||
|
|
||||||
iter_type it_;
|
iter_type it_{};
|
||||||
buffers_suffix const* b_ = nullptr;
|
buffers_suffix const* b_ = nullptr;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -49,8 +49,10 @@ public:
|
|||||||
std::bidirectional_iterator_tag;
|
std::bidirectional_iterator_tag;
|
||||||
|
|
||||||
const_iterator() = default;
|
const_iterator() = default;
|
||||||
const_iterator(const_iterator const& other) = default;
|
const_iterator(
|
||||||
const_iterator& operator=(const_iterator const& other) = default;
|
const_iterator const& other) = default;
|
||||||
|
const_iterator& operator=(
|
||||||
|
const_iterator const& other) = default;
|
||||||
|
|
||||||
bool
|
bool
|
||||||
operator==(const_iterator const& other) const
|
operator==(const_iterator const& other) const
|
||||||
@@ -67,9 +69,15 @@ public:
|
|||||||
reference
|
reference
|
||||||
operator*() const
|
operator*() const
|
||||||
{
|
{
|
||||||
|
#if 0
|
||||||
if(it_ == b_->begin_)
|
if(it_ == b_->begin_)
|
||||||
return value_type(*it_) + b_->skip_;
|
return value_type{*it_} + b_->skip_;
|
||||||
return value_type{*it_};
|
return value_type{*it_};
|
||||||
|
#else
|
||||||
|
return it_ == b_->begin_
|
||||||
|
? value_type{*it_} + b_->skip_
|
||||||
|
: *it_;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
pointer
|
pointer
|
||||||
@@ -200,13 +208,12 @@ void
|
|||||||
buffers_suffix<Buffers>::
|
buffers_suffix<Buffers>::
|
||||||
consume(std::size_t amount)
|
consume(std::size_t amount)
|
||||||
{
|
{
|
||||||
using net::buffer_size;
|
|
||||||
auto const end =
|
auto const end =
|
||||||
net::buffer_sequence_end(bs_);
|
net::buffer_sequence_end(bs_);
|
||||||
for(;amount > 0 && begin_ != end; ++begin_)
|
for(;amount > 0 && begin_ != end; ++begin_)
|
||||||
{
|
{
|
||||||
auto const len =
|
auto const len =
|
||||||
buffer_size(*begin_) - skip_;
|
net::buffer_size(*begin_) - skip_;
|
||||||
if(amount < len)
|
if(amount < len)
|
||||||
{
|
{
|
||||||
skip_ += amount;
|
skip_ += amount;
|
||||||
|
@@ -229,12 +229,14 @@ public:
|
|||||||
std::bidirectional_iterator_tag;
|
std::bidirectional_iterator_tag;
|
||||||
|
|
||||||
const_iterator() = default;
|
const_iterator() = default;
|
||||||
const_iterator(const_iterator const& other) = default;
|
const_iterator(
|
||||||
const_iterator& operator=(const_iterator const& other) = default;
|
const_iterator const& other) = default;
|
||||||
|
const_iterator& operator=(
|
||||||
|
const_iterator const& other) = default;
|
||||||
|
|
||||||
const_iterator(
|
const_iterator(
|
||||||
basic_multi_buffer const& b,
|
basic_multi_buffer const& b, typename
|
||||||
typename list_type::const_iterator const& it) noexcept
|
list_type::const_iterator const& it) noexcept
|
||||||
: b_(&b)
|
: b_(&b)
|
||||||
, it_(it)
|
, it_(it)
|
||||||
{
|
{
|
||||||
|
@@ -294,7 +294,8 @@ public:
|
|||||||
|
|
||||||
// VFALCO Some version of g++ incorrectly complain about
|
// VFALCO Some version of g++ incorrectly complain about
|
||||||
// uninitialized values when buffers_cat and
|
// uninitialized values when buffers_cat and
|
||||||
// buffers_prefix are used together.
|
// buffers_prefix and/or buffers_suffix are used
|
||||||
|
// together.
|
||||||
void
|
void
|
||||||
testGccWarning2()
|
testGccWarning2()
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user