diff options
Diffstat (limited to 'boost/beast/core')
-rw-r--r-- | boost/beast/core/buffers_adapter.hpp | 2 | ||||
-rw-r--r-- | boost/beast/core/detail/buffer.hpp | 83 | ||||
-rw-r--r-- | boost/beast/core/detail/empty_base_optimization.hpp | 100 | ||||
-rw-r--r-- | boost/beast/core/flat_buffer.hpp | 6 | ||||
-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 | ||||
-rw-r--r-- | boost/beast/core/multi_buffer.hpp | 6 | ||||
-rw-r--r-- | boost/beast/core/static_buffer.hpp | 2 | ||||
-rw-r--r-- | boost/beast/core/string.hpp | 30 |
15 files changed, 274 insertions, 198 deletions
diff --git a/boost/beast/core/buffers_adapter.hpp b/boost/beast/core/buffers_adapter.hpp index 0e0ce8b0c1..2000ce24bb 100644 --- a/boost/beast/core/buffers_adapter.hpp +++ b/boost/beast/core/buffers_adapter.hpp @@ -69,6 +69,8 @@ class buffers_adapter { } + iter_type end_impl() const; + public: /// The type of the underlying mutable buffer sequence using value_type = MutableBufferSequence; diff --git a/boost/beast/core/detail/buffer.hpp b/boost/beast/core/detail/buffer.hpp new file mode 100644 index 0000000000..d359d10059 --- /dev/null +++ b/boost/beast/core/detail/buffer.hpp @@ -0,0 +1,83 @@ +// +// Copyright (c) 2018 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +#ifndef BOOST_BEAST_CORE_DETAIL_BUFFER_HPP +#define BOOST_BEAST_CORE_DETAIL_BUFFER_HPP + +#include <boost/beast/core/error.hpp> +#include <boost/optional.hpp> +#include <stdexcept> + +namespace boost { +namespace beast { +namespace detail { + +template< + class DynamicBuffer, + class ErrorValue> +auto +dynamic_buffer_prepare_noexcept( + DynamicBuffer& buffer, + std::size_t size, + error_code& ec, + ErrorValue ev) -> + boost::optional<typename + DynamicBuffer::mutable_buffers_type> +{ + if(buffer.max_size() - buffer.size() < size) + { + // length error + ec = ev; + return boost::none; + } + boost::optional<typename + DynamicBuffer::mutable_buffers_type> result; + result.emplace(buffer.prepare(size)); + ec.assign(0, ec.category()); + return result; +} + +template< + class DynamicBuffer, + class ErrorValue> +auto +dynamic_buffer_prepare( + DynamicBuffer& buffer, + std::size_t size, + error_code& ec, + ErrorValue ev) -> + boost::optional<typename + DynamicBuffer::mutable_buffers_type> +{ +#ifndef BOOST_NO_EXCEPTIONS + try + { + boost::optional<typename + DynamicBuffer::mutable_buffers_type> result; + result.emplace(buffer.prepare(size)); + ec.assign(0, ec.category()); + return result; + } + catch(std::length_error const&) + { + ec = ev; + } + return boost::none; + +#else + return dynamic_buffer_prepare_noexcept( + buffer, size, ec, ev); +#endif +} + +} // detail +} // beast +} // boost + +#endif diff --git a/boost/beast/core/detail/empty_base_optimization.hpp b/boost/beast/core/detail/empty_base_optimization.hpp deleted file mode 100644 index b1e728b674..0000000000 --- a/boost/beast/core/detail/empty_base_optimization.hpp +++ /dev/null @@ -1,100 +0,0 @@ -// -// Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// -// Official repository: https://github.com/boostorg/beast -// - -#ifndef BOOST_BEAST_DETAIL_EMPTY_BASE_OPTIMIZATION_HPP -#define BOOST_BEAST_DETAIL_EMPTY_BASE_OPTIMIZATION_HPP - -#include <boost/type_traits/is_final.hpp> -#include <type_traits> -#include <utility> - -namespace boost { -namespace beast { -namespace detail { - -template<class T> -struct is_empty_base_optimization_derived - : std::integral_constant<bool, - std::is_empty<T>::value && - ! boost::is_final<T>::value> -{ -}; - -template<class T, int UniqueID = 0, - bool isDerived = - is_empty_base_optimization_derived<T>::value> -class empty_base_optimization : private T -{ -public: - empty_base_optimization() = default; - empty_base_optimization(empty_base_optimization&&) = default; - empty_base_optimization(empty_base_optimization const&) = default; - empty_base_optimization& operator=(empty_base_optimization&&) = default; - empty_base_optimization& operator=(empty_base_optimization const&) = default; - - template<class Arg1, class... ArgN> - explicit - empty_base_optimization(Arg1&& arg1, ArgN&&... argn) - : T(std::forward<Arg1>(arg1), - std::forward<ArgN>(argn)...) - { - } - - T& member() noexcept - { - return *this; - } - - T const& member() const noexcept - { - return *this; - } -}; - -//------------------------------------------------------------------------------ - -template< - class T, - int UniqueID -> -class empty_base_optimization <T, UniqueID, false> -{ - T t_; - -public: - empty_base_optimization() = default; - empty_base_optimization(empty_base_optimization&&) = default; - empty_base_optimization(empty_base_optimization const&) = default; - empty_base_optimization& operator=(empty_base_optimization&&) = default; - empty_base_optimization& operator=(empty_base_optimization const&) = default; - - template<class Arg1, class... ArgN> - explicit - empty_base_optimization(Arg1&& arg1, ArgN&&... argn) - : t_(std::forward<Arg1>(arg1), - std::forward<ArgN>(argn)...) - { - } - - T& member() noexcept - { - return t_; - } - - T const& member() const noexcept - { - return t_; - } -}; - -} // detail -} // beast -} // boost - -#endif diff --git a/boost/beast/core/flat_buffer.hpp b/boost/beast/core/flat_buffer.hpp index 11a18fdcb4..1e0f0ef519 100644 --- a/boost/beast/core/flat_buffer.hpp +++ b/boost/beast/core/flat_buffer.hpp @@ -12,8 +12,8 @@ #include <boost/beast/core/detail/config.hpp> #include <boost/beast/core/detail/allocator.hpp> -#include <boost/beast/core/detail/empty_base_optimization.hpp> #include <boost/asio/buffer.hpp> +#include <boost/core/empty_value.hpp> #include <limits> #include <memory> @@ -44,7 +44,7 @@ namespace beast { template<class Allocator> class basic_flat_buffer #if ! BOOST_BEAST_DOXYGEN - : private detail::empty_base_optimization< + : private boost::empty_value< typename detail::allocator_traits<Allocator>:: template rebind_alloc<char>> #endif @@ -218,7 +218,7 @@ public: allocator_type get_allocator() const { - return this->member(); + return this->get(); } /// Returns the size of the input sequence. 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; diff --git a/boost/beast/core/multi_buffer.hpp b/boost/beast/core/multi_buffer.hpp index ee14b419a5..046ed83a29 100644 --- a/boost/beast/core/multi_buffer.hpp +++ b/boost/beast/core/multi_buffer.hpp @@ -12,8 +12,8 @@ #include <boost/beast/core/detail/config.hpp> #include <boost/beast/core/detail/allocator.hpp> -#include <boost/beast/core/detail/empty_base_optimization.hpp> #include <boost/asio/buffer.hpp> +#include <boost/core/empty_value.hpp> #include <boost/intrusive/list.hpp> #include <iterator> #include <limits> @@ -37,7 +37,7 @@ namespace beast { template<class Allocator> class basic_multi_buffer #if ! BOOST_BEAST_DOXYGEN - : private detail::empty_base_optimization< + : private boost::empty_value< typename detail::allocator_traits<Allocator>:: template rebind_alloc<char>> #endif @@ -217,7 +217,7 @@ public: allocator_type get_allocator() const { - return this->member(); + return this->get(); } /// Returns the size of the input sequence. diff --git a/boost/beast/core/static_buffer.hpp b/boost/beast/core/static_buffer.hpp index 86f06b1efd..fa59638bb7 100644 --- a/boost/beast/core/static_buffer.hpp +++ b/boost/beast/core/static_buffer.hpp @@ -110,7 +110,7 @@ public: /** Move bytes from the output sequence to the input sequence. - @param size The nubmer of bytes to commit. If this is greater + @param size The number of bytes to commit. If this is greater than the size of the output sequence, the entire output sequence is committed. */ diff --git a/boost/beast/core/string.hpp b/boost/beast/core/string.hpp index 27bfa57165..de94d2e639 100644 --- a/boost/beast/core/string.hpp +++ b/boost/beast/core/string.hpp @@ -12,19 +12,35 @@ #include <boost/beast/core/detail/config.hpp> #include <boost/version.hpp> + +#if defined(BOOST_BEAST_USE_STD_STRING_VIEW) +#include <string_view> +#else #include <boost/utility/string_view.hpp> +#endif + #include <algorithm> namespace boost { namespace beast { -/// The type of string view used by the library -using string_view = boost::string_view; - -/// The type of basic string view used by the library -template<class CharT, class Traits> -using basic_string_view = - boost::basic_string_view<CharT, Traits>; +#if defined(BOOST_BEAST_USE_STD_STRING_VIEW) + /// The type of string view used by the library + using string_view = std::string_view; + + /// The type of basic string view used by the library + template<class CharT, class Traits> + using basic_string_view = + std::basic_string_view<CharT, Traits>; +#else + /// The type of string view used by the library + using string_view = boost::string_view; + + /// The type of basic string view used by the library + template<class CharT, class Traits> + using basic_string_view = + boost::basic_string_view<CharT, Traits>; +#endif namespace detail { |