diff --git a/CHANGELOG.md b/CHANGELOG.md index acac1f0d..8be2e17f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +Version 106: + +* Dynamic buffer input areas are mutable + +-------------------------------------------------------------------------------- + Version 105: * Fix compile error in websocket snippet diff --git a/include/boost/beast/core/flat_buffer.hpp b/include/boost/beast/core/flat_buffer.hpp index d6d5fa04..ab6f2b8e 100644 --- a/include/boost/beast/core/flat_buffer.hpp +++ b/include/boost/beast/core/flat_buffer.hpp @@ -84,7 +84,7 @@ public: using allocator_type = Allocator; /// The type used to represent the input sequence as a list of buffers. - using const_buffers_type = boost::asio::const_buffers_1; + using const_buffers_type = boost::asio::mutable_buffers_1; /// The type used to represent the output sequence as a list of buffers. using mutable_buffers_type = boost::asio::mutable_buffers_1; diff --git a/include/boost/beast/core/flat_static_buffer.hpp b/include/boost/beast/core/flat_static_buffer.hpp index 0f3ea3e0..54d670e0 100644 --- a/include/boost/beast/core/flat_static_buffer.hpp +++ b/include/boost/beast/core/flat_static_buffer.hpp @@ -52,7 +52,7 @@ public: This buffer sequence is guaranteed to have length 1. */ - using const_buffers_type = boost::asio::const_buffers_1; + using const_buffers_type = boost::asio::mutable_buffers_1; /** The type used to represent the mutable input sequence as a list of buffers. diff --git a/include/boost/beast/core/impl/buffers_adapter.ipp b/include/boost/beast/core/impl/buffers_adapter.ipp index 586bce5e..d88d6734 100644 --- a/include/boost/beast/core/impl/buffers_adapter.ipp +++ b/include/boost/beast/core/impl/buffers_adapter.ipp @@ -17,7 +17,6 @@ #include #include #include -#include namespace boost { namespace beast { @@ -29,7 +28,7 @@ class buffers_adapter:: buffers_adapter const* ba_; public: - using value_type = boost::asio::const_buffer; + using value_type = boost::asio::mutable_buffer; class const_iterator; diff --git a/include/boost/beast/core/impl/multi_buffer.ipp b/include/boost/beast/core/impl/multi_buffer.ipp index e69bf472..c55f396f 100644 --- a/include/boost/beast/core/impl/multi_buffer.ipp +++ b/include/boost/beast/core/impl/multi_buffer.ipp @@ -132,8 +132,7 @@ class basic_multi_buffer::const_buffers_type const_buffers_type(basic_multi_buffer const& b); public: - // Why? - using value_type = boost::asio::const_buffer; + using value_type = boost::asio::mutable_buffer; class const_iterator; diff --git a/include/boost/beast/core/impl/static_buffer.ipp b/include/boost/beast/core/impl/static_buffer.ipp index 36c59daf..9574cc4d 100644 --- a/include/boost/beast/core/impl/static_buffer.ipp +++ b/include/boost/beast/core/impl/static_buffer.ipp @@ -35,14 +35,19 @@ static_buffer_base:: data() const -> const_buffers_type { - using boost::asio::const_buffer; + using boost::asio::mutable_buffer; + const_buffers_type result; if(in_off_ + in_size_ <= capacity_) - return {{ - {const_buffer{begin_ + in_off_, in_size_}}, - {const_buffer{begin_, 0}}}}; - return {{ - {const_buffer{begin_ + in_off_, capacity_ - in_off_}}, - {const_buffer{begin_, in_size_ - (capacity_ - in_off_)}}}}; + { + result[0] = mutable_buffer{begin_ + in_off_, in_size_}; + result[1] = mutable_buffer{begin_, 0}; + } + else + { + result[0] = mutable_buffer{begin_ + in_off_, capacity_ - in_off_}; + result[1] = mutable_buffer{begin_, in_size_ - (capacity_ - in_off_)}; + } + return result; } inline @@ -52,13 +57,18 @@ mutable_data() -> mutable_data_type { using boost::asio::mutable_buffer; + mutable_data_type result; if(in_off_ + in_size_ <= capacity_) - return {{ - {mutable_buffer{begin_ + in_off_, in_size_}}, - {mutable_buffer{begin_, 0}}}}; - return {{ - {mutable_buffer{begin_ + in_off_, capacity_ - in_off_}}, - {mutable_buffer{begin_, in_size_ - (capacity_ - in_off_)}}}}; + { + result[0] = mutable_buffer{begin_ + in_off_, in_size_}; + result[1] = mutable_buffer{begin_, 0}; + } + else + { + result[0] = mutable_buffer{begin_ + in_off_, capacity_ - in_off_}; + result[1] = mutable_buffer{begin_, in_size_ - (capacity_ - in_off_)}; + } + return result; } inline @@ -73,13 +83,18 @@ prepare(std::size_t size) -> "buffer overflow"}); out_size_ = size; auto const out_off = (in_off_ + in_size_) % capacity_; + mutable_buffers_type result; if(out_off + out_size_ <= capacity_ ) - return {{ - {mutable_buffer{begin_ + out_off, out_size_}}, - {mutable_buffer{begin_, 0}}}}; - return {{ - {mutable_buffer{begin_ + out_off, capacity_ - out_off}}, - {mutable_buffer{begin_, out_size_ - (capacity_ - out_off)}}}}; + { + result[0] = mutable_buffer{begin_ + out_off, out_size_}; + result[1] = mutable_buffer{begin_, 0}; + } + else + { + result[0] = mutable_buffer{begin_ + out_off, capacity_ - out_off}; + result[1] = mutable_buffer{begin_, out_size_ - (capacity_ - out_off)}; + } + return result; } inline diff --git a/include/boost/beast/core/static_buffer.hpp b/include/boost/beast/core/static_buffer.hpp index 0a3e85e9..031de235 100644 --- a/include/boost/beast/core/static_buffer.hpp +++ b/include/boost/beast/core/static_buffer.hpp @@ -52,7 +52,7 @@ class static_buffer_base public: /// The type used to represent the input sequence as a list of buffers. using const_buffers_type = - std::array; + std::array; /// The type used to represent the mutable input sequence as a list of buffers. using mutable_data_type =