diff options
author | DongHun Kwak <dh0128.kwak@samsung.com> | 2019-12-05 15:21:30 +0900 |
---|---|---|
committer | DongHun Kwak <dh0128.kwak@samsung.com> | 2019-12-05 15:21:30 +0900 |
commit | d6a306e745acfee00e81ccaf3324a2a03516db41 (patch) | |
tree | 145a26368608982f40ebb0f4836185c44abb9ae4 /boost/beast/core/impl | |
parent | 5ce2ccf2f23c6d3de4c79f216f57ca6f2a18ed16 (diff) | |
download | boost-d6a306e745acfee00e81ccaf3324a2a03516db41.tar.gz boost-d6a306e745acfee00e81ccaf3324a2a03516db41.tar.bz2 boost-d6a306e745acfee00e81ccaf3324a2a03516db41.zip |
Imported Upstream version 1.69.0upstream/1.69.0
Diffstat (limited to 'boost/beast/core/impl')
-rw-r--r-- | boost/beast/core/impl/buffers_adapter.ipp | 88 | ||||
-rw-r--r-- | boost/beast/core/impl/buffers_cat.ipp | 19 | ||||
-rw-r--r-- | boost/beast/core/impl/buffers_prefix.ipp | 17 | ||||
-rw-r--r-- | boost/beast/core/impl/buffers_suffix.ipp | 15 | ||||
-rw-r--r-- | boost/beast/core/impl/flat_buffer.ipp | 40 | ||||
-rw-r--r-- | boost/beast/core/impl/multi_buffer.ipp | 58 | ||||
-rw-r--r-- | boost/beast/core/impl/read_size.ipp | 4 | ||||
-rw-r--r-- | boost/beast/core/impl/static_buffer.ipp | 2 |
8 files changed, 159 insertions, 84 deletions
diff --git a/boost/beast/core/impl/buffers_adapter.ipp b/boost/beast/core/impl/buffers_adapter.ipp index fa0872ae77..f077c521f0 100644 --- a/boost/beast/core/impl/buffers_adapter.ipp +++ b/boost/beast/core/impl/buffers_adapter.ipp @@ -26,7 +26,7 @@ template<class MutableBufferSequence> class buffers_adapter<MutableBufferSequence>:: const_buffers_type { - buffers_adapter const* ba_; + buffers_adapter const* b_; public: using value_type = boost::asio::const_buffer; @@ -48,8 +48,8 @@ public: private: friend class buffers_adapter; - const_buffers_type(buffers_adapter const& ba) - : ba_(&ba) + const_buffers_type(buffers_adapter const& b) + : b_(&b) { } }; @@ -59,7 +59,7 @@ class buffers_adapter<MutableBufferSequence>:: const_buffers_type::const_iterator { iter_type it_; - buffers_adapter const* ba_ = nullptr; + buffers_adapter const* b_ = nullptr; public: using value_type = boost::asio::const_buffer; @@ -78,8 +78,20 @@ public: bool operator==(const_iterator const& other) const { - return ba_ == other.ba_ && - it_ == other.it_; + return + (b_ == nullptr) ? + ( + other.b_ == nullptr || + other.it_ == other.b_->end_impl() + ):( + (other.b_ == nullptr) ? + ( + it_ == b_->end_impl() + ): ( + b_ == other.b_ && + it_ == other.it_ + ) + ); } bool @@ -93,9 +105,9 @@ public: { value_type const b = *it_; return value_type{b.data(), - (ba_->out_ == boost::asio::buffer_sequence_end(ba_->bs_) || - it_ != ba_->out_) ? b.size() : ba_->out_pos_} + - (it_ == ba_->begin_ ? ba_->in_pos_ : 0); + (b_->out_ == boost::asio::buffer_sequence_end(b_->bs_) || + it_ != b_->out_) ? b.size() : b_->out_pos_} + + (it_ == b_->begin_ ? b_->in_pos_ : 0); } pointer @@ -134,33 +146,30 @@ public: private: friend class const_buffers_type; - const_iterator(buffers_adapter const& ba, + const_iterator(buffers_adapter const& b, iter_type iter) : it_(iter) - , ba_(&ba) + , b_(&b) { } }; template<class MutableBufferSequence> -inline auto buffers_adapter<MutableBufferSequence>:: const_buffers_type::begin() const -> const_iterator { - return const_iterator{*ba_, ba_->begin_}; + return const_iterator{*b_, b_->begin_}; } template<class MutableBufferSequence> -inline auto buffers_adapter<MutableBufferSequence>:: const_buffers_type::end() const -> const_iterator { - return const_iterator{*ba_, ba_->out_ == - ba_->end_ ? ba_->end_ : std::next(ba_->out_)}; + return const_iterator{*b_, b_->end_impl()}; } //------------------------------------------------------------------------------ @@ -169,7 +178,7 @@ template<class MutableBufferSequence> class buffers_adapter<MutableBufferSequence>:: mutable_buffers_type { - buffers_adapter const* ba_; + buffers_adapter const* b_; public: using value_type = boost::asio::mutable_buffer; @@ -192,8 +201,8 @@ private: friend class buffers_adapter; mutable_buffers_type( - buffers_adapter const& ba) - : ba_(&ba) + buffers_adapter const& b) + : b_(&b) { } }; @@ -203,7 +212,7 @@ class buffers_adapter<MutableBufferSequence>:: mutable_buffers_type::const_iterator { iter_type it_; - buffers_adapter const* ba_ = nullptr; + buffers_adapter const* b_ = nullptr; public: using value_type = boost::asio::mutable_buffer; @@ -222,8 +231,20 @@ public: bool operator==(const_iterator const& other) const { - return ba_ == other.ba_ && - it_ == other.it_; + return + (b_ == nullptr) ? + ( + other.b_ == nullptr || + other.it_ == other.b_->end_ + ):( + (other.b_ == nullptr) ? + ( + it_ == b_->end_ + ): ( + b_ == other.b_ && + it_ == other.it_ + ) + ); } bool @@ -237,9 +258,9 @@ public: { value_type const b = *it_; return value_type{b.data(), - it_ == std::prev(ba_->end_) ? - ba_->out_end_ : b.size()} + - (it_ == ba_->out_ ? ba_->out_pos_ : 0); + it_ == std::prev(b_->end_) ? + b_->out_end_ : b.size()} + + (it_ == b_->out_ ? b_->out_pos_ : 0); } pointer @@ -278,10 +299,10 @@ public: private: friend class mutable_buffers_type; - const_iterator(buffers_adapter const& ba, + const_iterator(buffers_adapter const& b, iter_type iter) : it_(iter) - , ba_(&ba) + , b_(&b) { } }; @@ -294,7 +315,7 @@ mutable_buffers_type:: begin() const -> const_iterator { - return const_iterator{*ba_, ba_->out_}; + return const_iterator{*b_, b_->out_}; } template<class MutableBufferSequence> @@ -305,12 +326,21 @@ mutable_buffers_type:: end() const -> const_iterator { - return const_iterator{*ba_, ba_->end_}; + return const_iterator{*b_, b_->end_}; } //------------------------------------------------------------------------------ template<class MutableBufferSequence> +auto +buffers_adapter<MutableBufferSequence>:: +end_impl() const -> + iter_type +{ + return out_ == end_ ? end_ : std::next(out_); +} + +template<class MutableBufferSequence> buffers_adapter<MutableBufferSequence>:: buffers_adapter(buffers_adapter&& other) : buffers_adapter(std::move(other), diff --git a/boost/beast/core/impl/buffers_cat.ipp b/boost/beast/core/impl/buffers_cat.ipp index 2e82e887fc..9de1187f36 100644 --- a/boost/beast/core/impl/buffers_cat.ipp +++ b/boost/beast/core/impl/buffers_cat.ipp @@ -34,6 +34,8 @@ class buffers_cat_view<Bn...>::const_iterator struct past_end { + char unused = 0; // make g++8 happy + operator bool() const noexcept { return true; @@ -281,9 +283,20 @@ buffers_cat_view<Bn...>:: const_iterator:: operator==(const_iterator const& other) const { - if(bn_ != other.bn_) - return false; - return it_ == other.it_; + return + (bn_ == nullptr) ? + ( + other.bn_ == nullptr || + other.it_.index() == sizeof...(Bn) + ):( + (other.bn_ == nullptr) ? + ( + it_.index() == sizeof...(Bn) + ): ( + bn_ == other.bn_ && + it_ == other.it_ + ) + ); } template<class... Bn> diff --git a/boost/beast/core/impl/buffers_prefix.ipp b/boost/beast/core/impl/buffers_prefix.ipp index 783cf19c85..c595455d60 100644 --- a/boost/beast/core/impl/buffers_prefix.ipp +++ b/boost/beast/core/impl/buffers_prefix.ipp @@ -73,7 +73,20 @@ public: bool operator==(const_iterator const& other) const { - return b_ == other.b_ && it_ == other.it_; + return + (b_ == nullptr) ? + ( + other.b_ == nullptr || + other.it_ == other.b_->end_ + ):( + (other.b_ == nullptr) ? + ( + it_ == b_->end_ + ): ( + b_ == other.b_ && + it_ == other.it_ + ) + ); } bool @@ -139,6 +152,8 @@ private: } }; +//------------------------------------------------------------------------------ + template<class BufferSequence> void buffers_prefix_view<BufferSequence>:: diff --git a/boost/beast/core/impl/buffers_suffix.ipp b/boost/beast/core/impl/buffers_suffix.ipp index 4385fe500d..62b5f4634e 100644 --- a/boost/beast/core/impl/buffers_suffix.ipp +++ b/boost/beast/core/impl/buffers_suffix.ipp @@ -54,7 +54,20 @@ public: bool operator==(const_iterator const& other) const { - return b_ == other.b_ && it_ == other.it_; + return + (b_ == nullptr) ? + ( + other.b_ == nullptr || + other.it_ == boost::asio::buffer_sequence_end(other.b_->bs_) + ):( + (other.b_ == nullptr) ? + ( + it_ == boost::asio::buffer_sequence_end(b_->bs_) + ): ( + b_ == other.b_ && + it_ == other.it_ + ) + ); } bool diff --git a/boost/beast/core/impl/flat_buffer.ipp b/boost/beast/core/impl/flat_buffer.ipp index a3801c6739..afc843ac0d 100644 --- a/boost/beast/core/impl/flat_buffer.ipp +++ b/boost/beast/core/impl/flat_buffer.ipp @@ -29,7 +29,7 @@ basic_flat_buffer<Allocator>:: { if(begin_) alloc_traits::deallocate( - this->member(), begin_, dist(begin_, end_)); + this->get(), begin_, dist(begin_, end_)); } template<class Allocator> @@ -59,7 +59,7 @@ basic_flat_buffer(std::size_t limit) template<class Allocator> basic_flat_buffer<Allocator>:: basic_flat_buffer(Allocator const& alloc) - : detail::empty_base_optimization<base_alloc_type>(alloc) + : boost::empty_value<base_alloc_type>(boost::empty_init_t(), alloc) , begin_(nullptr) , in_(nullptr) , out_(nullptr) @@ -72,7 +72,7 @@ basic_flat_buffer(Allocator const& alloc) template<class Allocator> basic_flat_buffer<Allocator>:: basic_flat_buffer(std::size_t limit, Allocator const& alloc) - : detail::empty_base_optimization<base_alloc_type>(alloc) + : boost::empty_value<base_alloc_type>(boost::empty_init_t(), alloc) , begin_(nullptr) , in_(nullptr) , out_(nullptr) @@ -85,8 +85,8 @@ basic_flat_buffer(std::size_t limit, Allocator const& alloc) template<class Allocator> basic_flat_buffer<Allocator>:: basic_flat_buffer(basic_flat_buffer&& other) - : detail::empty_base_optimization<base_alloc_type>( - std::move(other.member())) + : boost::empty_value<base_alloc_type>(boost::empty_init_t(), + std::move(other.get())) , begin_(boost::exchange(other.begin_, nullptr)) , in_(boost::exchange(other.in_, nullptr)) , out_(boost::exchange(other.out_, nullptr)) @@ -101,9 +101,9 @@ template<class Allocator> basic_flat_buffer<Allocator>:: basic_flat_buffer(basic_flat_buffer&& other, Allocator const& alloc) - : detail::empty_base_optimization<base_alloc_type>(alloc) + : boost::empty_value<base_alloc_type>(boost::empty_init_t(), alloc) { - if(this->member() != other.member()) + if(this->get() != other.get()) { begin_ = nullptr; in_ = nullptr; @@ -133,9 +133,9 @@ basic_flat_buffer(basic_flat_buffer&& other, template<class Allocator> basic_flat_buffer<Allocator>:: basic_flat_buffer(basic_flat_buffer const& other) - : detail::empty_base_optimization<base_alloc_type>( + : boost::empty_value<base_alloc_type>(boost::empty_init_t(), alloc_traits::select_on_container_copy_construction( - other.member())) + other.get())) , begin_(nullptr) , in_(nullptr) , out_(nullptr) @@ -150,7 +150,7 @@ template<class Allocator> basic_flat_buffer<Allocator>:: basic_flat_buffer(basic_flat_buffer const& other, Allocator const& alloc) - : detail::empty_base_optimization<base_alloc_type>(alloc) + : boost::empty_value<base_alloc_type>(boost::empty_init_t(), alloc) , begin_(nullptr) , in_(nullptr) , out_(nullptr) @@ -181,7 +181,7 @@ template<class OtherAlloc> basic_flat_buffer<Allocator>:: basic_flat_buffer(basic_flat_buffer<OtherAlloc> const& other, Allocator const& alloc) - : detail::empty_base_optimization<base_alloc_type>(alloc) + : boost::empty_value<base_alloc_type>(boost::empty_init_t(), alloc) , begin_(nullptr) , in_(nullptr) , out_(nullptr) @@ -264,14 +264,14 @@ prepare(std::size_t n) -> max_, (std::max<std::size_t>)(2 * len, len + n)); auto const p = alloc_traits::allocate( - this->member(), new_size); + this->get(), new_size); if(begin_) { BOOST_ASSERT(p); BOOST_ASSERT(in_); std::memcpy(p, in_, len); alloc_traits::deallocate( - this->member(), begin_, capacity()); + this->get(), begin_, capacity()); } begin_ = p; in_ = begin_; @@ -309,7 +309,7 @@ shrink_to_fit() BOOST_ASSERT(begin_); BOOST_ASSERT(in_); p = alloc_traits::allocate( - this->member(), len); + this->get(), len); std::memcpy(p, in_, len); } else @@ -317,7 +317,7 @@ shrink_to_fit() p = nullptr; } alloc_traits::deallocate( - this->member(), begin_, dist(begin_, end_)); + this->get(), begin_, dist(begin_, end_)); begin_ = p; in_ = begin_; out_ = begin_ + len; @@ -358,7 +358,7 @@ basic_flat_buffer<Allocator>:: move_assign(basic_flat_buffer& other, std::true_type) { reset(); - this->member() = std::move(other.member()); + this->get() = std::move(other.get()); begin_ = other.begin_; in_ = other.in_; out_ = other.out_; @@ -379,7 +379,7 @@ basic_flat_buffer<Allocator>:: move_assign(basic_flat_buffer& other, std::false_type) { reset(); - if(this->member() != other.member()) + if(this->get() != other.get()) { copy_from(other); other.reset(); @@ -398,7 +398,7 @@ copy_assign(basic_flat_buffer const& other, std::true_type) { reset(); max_ = other.max_; - this->member() = other.member(); + this->get() = other.get(); copy_from(other); } @@ -430,7 +430,7 @@ basic_flat_buffer<Allocator>:: swap(basic_flat_buffer& other, std::true_type) { using std::swap; - swap(this->member(), other.member()); + swap(this->get(), other.get()); swap(max_, other.max_); swap(begin_, other.begin_); swap(in_, other.in_); @@ -446,7 +446,7 @@ void basic_flat_buffer<Allocator>:: swap(basic_flat_buffer& other, std::false_type) { - BOOST_ASSERT(this->member() == other.member()); + BOOST_ASSERT(this->get() == other.get()); using std::swap; swap(max_, other.max_); swap(begin_, other.begin_); diff --git a/boost/beast/core/impl/multi_buffer.ipp b/boost/beast/core/impl/multi_buffer.ipp index 0b35decd05..fb48424a3a 100644 --- a/boost/beast/core/impl/multi_buffer.ipp +++ b/boost/beast/core/impl/multi_buffer.ipp @@ -440,8 +440,8 @@ basic_multi_buffer(std::size_t limit) template<class Allocator> basic_multi_buffer<Allocator>:: basic_multi_buffer(Allocator const& alloc) - : detail::empty_base_optimization< - base_alloc_type>(alloc) + : boost::empty_value< + base_alloc_type>(boost::empty_init_t(), alloc) , out_(list_.end()) { } @@ -450,8 +450,8 @@ template<class Allocator> basic_multi_buffer<Allocator>:: basic_multi_buffer(std::size_t limit, Allocator const& alloc) - : detail::empty_base_optimization< - base_alloc_type>(alloc) + : boost::empty_value< + base_alloc_type>(boost::empty_init_t(), alloc) , max_(limit) , out_(list_.end()) { @@ -460,8 +460,8 @@ basic_multi_buffer(std::size_t limit, template<class Allocator> basic_multi_buffer<Allocator>:: basic_multi_buffer(basic_multi_buffer&& other) - : detail::empty_base_optimization< - base_alloc_type>(std::move(other.member())) + : boost::empty_value< + base_alloc_type>(boost::empty_init_t(), std::move(other.get())) , max_(other.max_) , in_size_(boost::exchange(other.in_size_, 0)) , in_pos_(boost::exchange(other.in_pos_, 0)) @@ -479,11 +479,11 @@ template<class Allocator> basic_multi_buffer<Allocator>:: basic_multi_buffer(basic_multi_buffer&& other, Allocator const& alloc) - : detail::empty_base_optimization< - base_alloc_type>(alloc) + : boost::empty_value< + base_alloc_type>(boost::empty_init_t(), alloc) , max_(other.max_) { - if(this->member() != other.member()) + if(this->get() != other.get()) { out_ = list_.end(); copy_from(other); @@ -510,10 +510,10 @@ basic_multi_buffer(basic_multi_buffer&& other, template<class Allocator> basic_multi_buffer<Allocator>:: basic_multi_buffer(basic_multi_buffer const& other) - : detail::empty_base_optimization< - base_alloc_type>(alloc_traits:: + : boost::empty_value< + base_alloc_type>(boost::empty_init_t(), alloc_traits:: select_on_container_copy_construction( - other.member())) + other.get())) , max_(other.max_) , out_(list_.end()) { @@ -524,8 +524,8 @@ template<class Allocator> basic_multi_buffer<Allocator>:: basic_multi_buffer(basic_multi_buffer const& other, Allocator const& alloc) - : detail::empty_base_optimization< - base_alloc_type>(alloc) + : boost::empty_value< + base_alloc_type>(boost::empty_init_t(), alloc) , max_(other.max_) , out_(list_.end()) { @@ -548,8 +548,8 @@ basic_multi_buffer<Allocator>:: basic_multi_buffer( basic_multi_buffer<OtherAlloc> const& other, allocator_type const& alloc) - : detail::empty_base_optimization< - base_alloc_type>(alloc) + : boost::empty_value< + base_alloc_type>(boost::empty_init_t(), alloc) , max_(other.max_) , out_(list_.end()) { @@ -689,8 +689,8 @@ prepare(size_type n) -> auto& e = *it++; reuse.erase(list_.iterator_to(e)); auto const len = sizeof(e) + e.size(); - alloc_traits::destroy(this->member(), &e); - alloc_traits::deallocate(this->member(), + alloc_traits::destroy(this->get(), &e); + alloc_traits::deallocate(this->get(), reinterpret_cast<char*>(&e), len); } if(n > 0) @@ -705,9 +705,9 @@ prepare(size_type n) -> 512, n})); auto& e = *reinterpret_cast<element*>(static_cast< - void*>(alloc_traits::allocate(this->member(), + void*>(alloc_traits::allocate(this->get(), sizeof(element) + size))); - alloc_traits::construct(this->member(), &e, size); + alloc_traits::construct(this->get(), &e, size); list_.push_back(e); if(out_ == list_.end()) out_ = list_.iterator_to(e); @@ -795,8 +795,8 @@ consume(size_type n) auto& e = list_.front(); list_.erase(list_.iterator_to(e)); auto const len = sizeof(e) + e.size(); - alloc_traits::destroy(this->member(), &e); - alloc_traits::deallocate(this->member(), + alloc_traits::destroy(this->get(), &e); + alloc_traits::deallocate(this->get(), reinterpret_cast<char*>(&e), len); #if BOOST_BEAST_MULTI_BUFFER_DEBUG_CHECK debug_check(); @@ -845,8 +845,8 @@ delete_list() { auto& e = *iter++; auto const len = sizeof(e) + e.size(); - alloc_traits::destroy(this->member(), &e); - alloc_traits::deallocate(this->member(), + alloc_traits::destroy(this->get(), &e); + alloc_traits::deallocate(this->get(), reinterpret_cast<char*>(&e), len); } } @@ -886,7 +886,7 @@ void basic_multi_buffer<Allocator>:: move_assign(basic_multi_buffer& other, std::false_type) { - if(this->member() != other.member()) + if(this->get() != other.get()) { copy_from(other); other.reset(); @@ -903,7 +903,7 @@ void basic_multi_buffer<Allocator>:: move_assign(basic_multi_buffer& other, std::true_type) { - this->member() = std::move(other.member()); + this->get() = std::move(other.get()); auto const at_end = other.out_ == other.list_.end(); list_ = std::move(other.list_); @@ -942,7 +942,7 @@ copy_assign( { reset(); max_ = other.max_; - this->member() = other.member(); + this->get() = other.get(); copy_from(other); } @@ -967,7 +967,7 @@ swap(basic_multi_buffer& other, std::true_type) out_ == list_.end(); auto const at_end1 = other.out_ == other.list_.end(); - swap(this->member(), other.member()); + swap(this->get(), other.get()); swap(list_, other.list_); swap(out_, other.out_); if(at_end1) @@ -986,7 +986,7 @@ void basic_multi_buffer<Allocator>:: swap(basic_multi_buffer& other, std::false_type) { - BOOST_ASSERT(this->member() == other.member()); + BOOST_ASSERT(this->get() == other.get()); using std::swap; auto const at_end0 = out_ == list_.end(); diff --git a/boost/beast/core/impl/read_size.ipp b/boost/beast/core/impl/read_size.ipp index ddcaf397a9..fa52571e09 100644 --- a/boost/beast/core/impl/read_size.ipp +++ b/boost/beast/core/impl/read_size.ipp @@ -10,6 +10,10 @@ #ifndef BOOST_BEAST_IMPL_READ_SIZE_IPP #define BOOST_BEAST_IMPL_READ_SIZE_IPP +#include <boost/assert.hpp> +#include <stdexcept> +#include <type_traits> + namespace boost { namespace beast { diff --git a/boost/beast/core/impl/static_buffer.ipp b/boost/beast/core/impl/static_buffer.ipp index 9615fb2d3c..bd498c97a1 100644 --- a/boost/beast/core/impl/static_buffer.ipp +++ b/boost/beast/core/impl/static_buffer.ipp @@ -119,7 +119,7 @@ consume(std::size_t size) else { // rewind the offset, so the next call to prepare - // can have a longer continguous segment. this helps + // can have a longer contiguous segment. this helps // algorithms optimized for larger buffesr. in_off_ = 0; in_size_ = 0; |