forked from boostorg/beast
Refactor buffers_range:
* Add tests * Increase code coverage * Correct behavior for default constructed iterators
This commit is contained in:
@@ -46,9 +46,13 @@ public:
|
||||
buffer_sequence_iterator<BufferSequence>::type;
|
||||
|
||||
iter_type it_;
|
||||
buffers_range_adaptor const* b_ = nullptr;
|
||||
|
||||
const_iterator(iter_type const& it)
|
||||
const_iterator(
|
||||
buffers_range_adaptor const& b,
|
||||
iter_type const& it)
|
||||
: it_(it)
|
||||
, b_(&b)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -60,17 +64,19 @@ public:
|
||||
using difference_type = std::ptrdiff_t;
|
||||
using iterator_category =
|
||||
std::bidirectional_iterator_tag;
|
||||
|
||||
|
||||
const_iterator() = default;
|
||||
|
||||
bool
|
||||
operator==(const_iterator const& other) const
|
||||
{
|
||||
return it_ == other.it_;
|
||||
return b_ == other.b_ && it_ == other.it_;
|
||||
}
|
||||
|
||||
bool
|
||||
operator!=(const_iterator const& other) const
|
||||
{
|
||||
return ! (*this == other);
|
||||
return !(*this == other);
|
||||
}
|
||||
|
||||
reference
|
||||
@@ -97,7 +103,6 @@ public:
|
||||
return temp;
|
||||
}
|
||||
|
||||
// deprecated
|
||||
const_iterator&
|
||||
operator--()
|
||||
{
|
||||
@@ -105,7 +110,6 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
// deprecated
|
||||
const_iterator
|
||||
operator--(int)
|
||||
{
|
||||
@@ -121,16 +125,21 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
buffers_range_adaptor(
|
||||
buffers_range_adaptor const&) = default;
|
||||
buffers_range_adaptor& operator=(
|
||||
buffers_range_adaptor const&) = default;
|
||||
|
||||
const_iterator
|
||||
begin() const noexcept
|
||||
{
|
||||
return net::buffer_sequence_begin(b_);
|
||||
return {*this, net::buffer_sequence_begin(b_)};
|
||||
}
|
||||
|
||||
const_iterator
|
||||
end() const noexcept
|
||||
{
|
||||
return net::buffer_sequence_end(b_);
|
||||
return {*this, net::buffer_sequence_end(b_)};
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user