diff --git a/CHANGELOG.md b/CHANGELOG.md index 49cc8ca6..0b141427 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ Version 209: * Qualify buffer_copy, don't qualify buffer_size * Add dynamic_buffer_ref * Refactor quickref.xml +* Add buffer_size -------------------------------------------------------------------------------- diff --git a/doc/qbk/03_core/4_buffers.qbk b/doc/qbk/03_core/4_buffers.qbk index 7d8a0637..be6cbd7b 100644 --- a/doc/qbk/03_core/4_buffers.qbk +++ b/doc/qbk/03_core/4_buffers.qbk @@ -20,6 +20,14 @@ transferred. [table Buffer Algorithms and Types [[Name][Description]] +[[ + [link beast.ref.boost__beast__buffer_size `buffer_size`] +][ + This is a more reliable version of + [@boost:/doc/html/boost_asio/reference/buffer_size.html `net::buffer_size`] + which is easier to use and also works for types which are convertible + to `net::const_buffer` or `net::mutable_buffer`. +]] [[ [link beast.ref.boost__beast__buffers_cat `buffers_cat`] ][ diff --git a/doc/qbk/quickref.xml b/doc/qbk/quickref.xml index 1851a702..553f795c 100644 --- a/doc/qbk/quickref.xml +++ b/doc/qbk/quickref.xml @@ -66,6 +66,7 @@ bind_back_handler 🞲 bind_front_handler 🞲 bind_handler + buffer_size 🞲 close_socket 🞲 generic_category get_lowest_layer 🞲 diff --git a/include/boost/beast/_experimental/core/detail/flat_stream.hpp b/include/boost/beast/_experimental/core/detail/flat_stream.hpp index c4bde08f..36e67195 100644 --- a/include/boost/beast/_experimental/core/detail/flat_stream.hpp +++ b/include/boost/beast/_experimental/core/detail/flat_stream.hpp @@ -10,6 +10,7 @@ #ifndef BOOST_BEAST_CORE_DETAIL_FLAT_STREAM_HPP #define BOOST_BEAST_CORE_DETAIL_FLAT_STREAM_HPP +#include #include #include @@ -42,7 +43,6 @@ public: auto last = net::buffer_sequence_end(buffers); if(first != last) { - using net::buffer_size; result.size = buffer_size(*first); if(result.size < limit) { diff --git a/include/boost/beast/_experimental/http/impl/icy_stream.hpp b/include/boost/beast/_experimental/http/impl/icy_stream.hpp index e390a9ac..6b90177f 100644 --- a/include/boost/beast/_experimental/http/impl/icy_stream.hpp +++ b/include/boost/beast/_experimental/http/impl/icy_stream.hpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -44,7 +45,6 @@ buffer_shift(MutableBuffers const& out, ConstBuffers const& in) auto out_pos = net::buffer_sequence_end(out); auto const in_begin = net::buffer_sequence_begin(in); auto const out_begin = net::buffer_sequence_begin(out); - using net::buffer_size; BOOST_ASSERT(buffer_size(in) == buffer_size(out)); if(in_pos == in_begin || out_pos == out_begin) return; diff --git a/include/boost/beast/_experimental/test/impl/stream.hpp b/include/boost/beast/_experimental/test/impl/stream.hpp index c9190cb6..189a4a64 100644 --- a/include/boost/beast/_experimental/test/impl/stream.hpp +++ b/include/boost/beast/_experimental/test/impl/stream.hpp @@ -10,6 +10,7 @@ #ifndef BOOST_BEAST_TEST_IMPL_STREAM_HPP #define BOOST_BEAST_TEST_IMPL_STREAM_HPP +#include #include #include @@ -110,7 +111,6 @@ stream:: str() const { auto const bs = in_->b.data(); - using net::buffer_size; if(buffer_size(bs) == 0) return {}; auto const b = beast::buffers_front(bs); @@ -189,7 +189,6 @@ read_some(MutableBufferSequence const& buffers, "MutableBufferSequence requirements not met"); if(in_->fc && in_->fc->fail(ec)) return 0; - using net::buffer_size; if(buffer_size(buffers) == 0) { ec.clear(); @@ -252,7 +251,6 @@ async_read_some( { std::unique_lock lock{in_->m}; BOOST_ASSERT(! in_->op); - using net::buffer_size; if( buffer_size(buffers) == 0 || buffer_size(in_->b.data()) > 0) { @@ -328,7 +326,6 @@ write_some( BOOST_ASSERT(out->code == status::ok); if(in_->fc && in_->fc->fail(ec)) return 0; - using net::buffer_size; auto const n = std::min( buffer_size(buffers), in_->write_max); std::unique_lock lock{out->m}; @@ -379,7 +376,6 @@ async_write_some(ConstBufferSequence const& buffers, } else { - using net::buffer_size; auto const n = std::min( buffer_size(buffers), in_->write_max); std::unique_lock lock{out->m}; diff --git a/include/boost/beast/core.hpp b/include/boost/beast/core.hpp index b337317b..374b63ab 100644 --- a/include/boost/beast/core.hpp +++ b/include/boost/beast/core.hpp @@ -14,6 +14,7 @@ #include #include +#include #include #include #include diff --git a/include/boost/beast/core/buffer_size.hpp b/include/boost/beast/core/buffer_size.hpp new file mode 100644 index 00000000..36d1f1e4 --- /dev/null +++ b/include/boost/beast/core/buffer_size.hpp @@ -0,0 +1,124 @@ +// +// 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_BUFFER_SIZE_HPP +#define BOOST_BEAST_BUFFER_SIZE_HPP + +#include +#include +#include +#include +#include +#include + +namespace boost { +namespace beast { + +namespace detail { + +template +struct has_buffer_size_impl : std::false_type +{ +}; + +template +struct has_buffer_size_impl() = + std::declval().buffer_size_impl())>> + : std::true_type +{ +}; + +struct buffer_size_impl +{ + template< + class B, + class = typename std::enable_if< + std::is_convertible< + B, net::const_buffer>::value>::type> + std::size_t + operator()(B const& b) const + { + return net::const_buffer(b).size(); + } + + template< + class B, + class = typename std::enable_if< + ! std::is_convertible< + B, net::const_buffer>::value>::type, + class = typename std::enable_if< + net::is_const_buffer_sequence::value && + ! has_buffer_size_impl::value>::type> + std::size_t + operator()(B const& b) const + { + using net::buffer_size; + return buffer_size(b); + } + + template< + class B, + class = typename std::enable_if< + ! std::is_convertible::value>::type, + class = typename std::enable_if< + net::is_const_buffer_sequence::value>::type, + class = typename std::enable_if< + has_buffer_size_impl::value>::type> + std::size_t + operator()(B const& b) const + { + return b.buffer_size_impl(); + } +}; + +} // detail + +/** Return the total number of bytes in a buffer or buffer sequence + + This function returns the total number of bytes in a buffer, + buffer sequence, or object convertible to a buffer. Specifically + it may be passed: + + @li A ConstBufferSequence or MutableBufferSequence + + @li A `net::const_buffer` or `net::mutable_buffer` + + @li An object convertible to `net::const_buffer` + + This function is designed as an easier-to-use replacement for + `net::buffer_size`. It recognizes customization points found through + argument-dependent lookup. The call `beast::buffer_size(b)` is + equivalent to performing: + @code + using namespace net; + buffer_size(b); + @endcode + In addition this handles types which are convertible to + `net::const_buffer`; these are not handled by `net::buffer_size`. + + @note It is expected that a future version of Networking will + incorporate the features of this function. + + @param buffers The buffer or buffer sequence to calculate the size of. + + @return The total number of bytes in the buffer or sequence. +*/ +#if BOOST_BEAST_DOXYGEN +template +void +buffer_size(Buffers const& buffers); +#else +BOOST_BEAST_INLINE_VARIABLE(buffer_size, detail::buffer_size_impl) +#endif + +} // beast +} // boost + +#endif diff --git a/include/boost/beast/core/buffers_prefix.hpp b/include/boost/beast/core/buffers_prefix.hpp index 50fe0a71..87d60c0f 100644 --- a/include/boost/beast/core/buffers_prefix.hpp +++ b/include/boost/beast/core/buffers_prefix.hpp @@ -11,6 +11,7 @@ #define BOOST_BEAST_BUFFERS_PREFIX_HPP #include +#include #include #include // for in_place_init_t #include @@ -128,25 +129,14 @@ public: end() const; #if ! BOOST_BEAST_DOXYGEN - template - friend std::size_t - buffer_size(buffers_prefix_view const& buffers); + buffer_size_impl() const noexcept + { + return size_; + } #endif }; -#ifndef BOOST_BEAST_DOXYGEN -BOOST_BEAST_DECL -std::size_t -buffer_size(buffers_prefix_view< - net::const_buffer> const& buffers); - -BOOST_BEAST_DECL -std::size_t -buffer_size(buffers_prefix_view< - net::mutable_buffer> const& buffers); -#endif - //------------------------------------------------------------------------------ /** Returns a prefix of a constant or mutable buffer sequence. diff --git a/include/boost/beast/core/buffers_suffix.hpp b/include/boost/beast/core/buffers_suffix.hpp index d3f2028d..15b4baeb 100644 --- a/include/boost/beast/core/buffers_suffix.hpp +++ b/include/boost/beast/core/buffers_suffix.hpp @@ -44,7 +44,6 @@ namespace beast { void send(SyncWriteStream& stream, ConstBufferSequence const& buffers) { buffers_suffix bs{buffers}; - using net::buffer_size; while(buffer_size(bs) > 0) bs.consume(stream.write_some(bs)); } diff --git a/include/boost/beast/core/buffers_to_string.hpp b/include/boost/beast/core/buffers_to_string.hpp index a36ced58..0d93e312 100644 --- a/include/boost/beast/core/buffers_to_string.hpp +++ b/include/boost/beast/core/buffers_to_string.hpp @@ -11,6 +11,7 @@ #define BOOST_BEAST_BUFFERS_TO_STRING_HPP #include +#include #include #include #include @@ -48,9 +49,8 @@ buffers_to_string(ConstBufferSequence const& buffers) net::is_const_buffer_sequence::value, "ConstBufferSequence requirements not met"); std::string result; - using net::buffer_size; result.reserve(buffer_size(buffers)); - for(auto const buffer : beast::buffers_range_ref(buffers)) + for(auto const buffer : buffers_range_ref(buffers)) result.append(static_cast( buffer.data()), buffer.size()); return result; diff --git a/include/boost/beast/core/detail/chacha.hpp b/include/boost/beast/core/detail/chacha.hpp index 976ade56..32519d07 100644 --- a/include/boost/beast/core/detail/chacha.hpp +++ b/include/boost/beast/core/detail/chacha.hpp @@ -35,7 +35,6 @@ #include #include -#include namespace boost { namespace beast { @@ -44,151 +43,82 @@ namespace detail { template class chacha { - void generate_block(); - void chacha_core(); - alignas(16) std::uint32_t block_[16]; std::uint32_t keysetup_[8]; std::uint64_t ctr_ = 0; int idx_ = 16; + void generate_block() + { + std::uint32_t constexpr constants[4] = { + 0x61707865, 0x3320646e, 0x79622d32, 0x6b206574 }; + std::uint32_t input[16]; + for (int i = 0; i < 4; ++i) + input[i] = constants[i]; + for (int i = 0; i < 8; ++i) + input[4 + i] = keysetup_[i]; + input[12] = (ctr_ / 16) & 0xffffffffu; + input[13] = (ctr_ / 16) >> 32; + input[14] = input[15] = 0xdeadbeef; // Could use 128-bit counter. + for (int i = 0; i < 16; ++i) + block_[i] = input[i]; + chacha_core(); + for (int i = 0; i < 16; ++i) + block_[i] += input[i]; + } + + void chacha_core() + { + #define BOOST_BEAST_CHACHA_ROTL32(x, n) (((x) << (n)) | ((x) >> (32 - (n)))) + + #define BOOST_BEAST_CHACHA_QUARTERROUND(x, a, b, c, d) \ + x[a] = x[a] + x[b]; x[d] ^= x[a]; x[d] = BOOST_BEAST_CHACHA_ROTL32(x[d], 16); \ + x[c] = x[c] + x[d]; x[b] ^= x[c]; x[b] = BOOST_BEAST_CHACHA_ROTL32(x[b], 12); \ + x[a] = x[a] + x[b]; x[d] ^= x[a]; x[d] = BOOST_BEAST_CHACHA_ROTL32(x[d], 8); \ + x[c] = x[c] + x[d]; x[b] ^= x[c]; x[b] = BOOST_BEAST_CHACHA_ROTL32(x[b], 7) + + for (unsigned i = 0; i < R; i += 2) + { + BOOST_BEAST_CHACHA_QUARTERROUND(block_, 0, 4, 8, 12); + BOOST_BEAST_CHACHA_QUARTERROUND(block_, 1, 5, 9, 13); + BOOST_BEAST_CHACHA_QUARTERROUND(block_, 2, 6, 10, 14); + BOOST_BEAST_CHACHA_QUARTERROUND(block_, 3, 7, 11, 15); + BOOST_BEAST_CHACHA_QUARTERROUND(block_, 0, 5, 10, 15); + BOOST_BEAST_CHACHA_QUARTERROUND(block_, 1, 6, 11, 12); + BOOST_BEAST_CHACHA_QUARTERROUND(block_, 2, 7, 8, 13); + BOOST_BEAST_CHACHA_QUARTERROUND(block_, 3, 4, 9, 14); + } + + #undef BOOST_BEAST_CHACHA_QUARTERROUND + #undef BOOST_BEAST_CHACHA_ROTL32 + } + public: static constexpr std::size_t state_size = sizeof(chacha::keysetup_); using result_type = std::uint32_t; - chacha(std::uint32_t const* v, std::uint64_t stream); - - std::uint32_t - operator()(); - -#if 0 - template - friend - bool - operator==(chacha const& lhs, chacha const& rhs); - - template - friend - bool - operator!=(chacha const& lhs, chacha const& rhs); - - static - constexpr - std::uint32_t - min() + chacha(std::uint32_t const* v, std::uint64_t stream) { - return (std::numeric_limits::min)(); + for (int i = 0; i < 6; ++i) + keysetup_[i] = v[i]; + keysetup_[6] = v[6] + (stream & 0xffffffff); + keysetup_[7] = v[7] + ((stream >> 32) & 0xffffffff); } - static - constexpr std::uint32_t - max() + operator()() { - return (std::numeric_limits::max)(); + if(idx_ == 16) + { + idx_ = 0; + ++ctr_; + generate_block(); + } + return block_[idx_++]; } -#endif }; -template -chacha:: -chacha(std::uint32_t const* v, std::uint64_t stream) -{ - for (int i = 0; i < 6; ++i) - keysetup_[i] = v[i]; - keysetup_[6] = v[6] + (stream & 0xffffffff); - keysetup_[7] = v[7] + ((stream >> 32) & 0xffffffff); -} - -template -std::uint32_t -chacha:: -operator()() -{ - if(idx_ == 16) - { - idx_ = 0; - ++ctr_; - generate_block(); - } - return block_[idx_++]; -} - -template -void -chacha:: -generate_block() -{ - std::uint32_t constexpr constants[4] = { - 0x61707865, 0x3320646e, 0x79622d32, 0x6b206574 }; - std::uint32_t input[16]; - for (int i = 0; i < 4; ++i) - input[i] = constants[i]; - for (int i = 0; i < 8; ++i) - input[4 + i] = keysetup_[i]; - input[12] = (ctr_ / 16) & 0xffffffffu; - input[13] = (ctr_ / 16) >> 32; - input[14] = input[15] = 0xdeadbeef; // Could use 128-bit counter. - for (int i = 0; i < 16; ++i) - block_[i] = input[i]; - chacha_core(); - for (int i = 0; i < 16; ++i) - block_[i] += input[i]; -} - -template -void -chacha:: -chacha_core() -{ - #define BOOST_BEAST_CHACHA_ROTL32(x, n) (((x) << (n)) | ((x) >> (32 - (n)))) - - #define BOOST_BEAST_CHACHA_QUARTERROUND(x, a, b, c, d) \ - x[a] = x[a] + x[b]; x[d] ^= x[a]; x[d] = BOOST_BEAST_CHACHA_ROTL32(x[d], 16); \ - x[c] = x[c] + x[d]; x[b] ^= x[c]; x[b] = BOOST_BEAST_CHACHA_ROTL32(x[b], 12); \ - x[a] = x[a] + x[b]; x[d] ^= x[a]; x[d] = BOOST_BEAST_CHACHA_ROTL32(x[d], 8); \ - x[c] = x[c] + x[d]; x[b] ^= x[c]; x[b] = BOOST_BEAST_CHACHA_ROTL32(x[b], 7) - - for (unsigned i = 0; i < R; i += 2) - { - BOOST_BEAST_CHACHA_QUARTERROUND(block_, 0, 4, 8, 12); - BOOST_BEAST_CHACHA_QUARTERROUND(block_, 1, 5, 9, 13); - BOOST_BEAST_CHACHA_QUARTERROUND(block_, 2, 6, 10, 14); - BOOST_BEAST_CHACHA_QUARTERROUND(block_, 3, 7, 11, 15); - BOOST_BEAST_CHACHA_QUARTERROUND(block_, 0, 5, 10, 15); - BOOST_BEAST_CHACHA_QUARTERROUND(block_, 1, 6, 11, 12); - BOOST_BEAST_CHACHA_QUARTERROUND(block_, 2, 7, 8, 13); - BOOST_BEAST_CHACHA_QUARTERROUND(block_, 3, 4, 9, 14); - } - - #undef BOOST_BEAST_CHACHA_QUARTERROUND - #undef BOOST_BEAST_CHACHA_ROTL32 -} - -//#endif - -#if 0 -// Implement interface. - -template -bool -operator==(chacha const& lhs, chacha const& rhs) -{ - for (int i = 0; i < 8; ++i) - if (lhs.keysetup_[i] != rhs.keysetup_[i]) - return false; - return lhs.ctr_ == rhs.ctr_; -} - -template -bool -operator!=(chacha const& lhs, chacha const& rhs) -{ - return !(lhs == rhs); -} -#endif - } // detail } // beast } // boost diff --git a/include/boost/beast/core/detail/config.hpp b/include/boost/beast/core/detail/config.hpp index 2476d83b..9b05e98d 100644 --- a/include/boost/beast/core/detail/config.hpp +++ b/include/boost/beast/core/detail/config.hpp @@ -76,7 +76,7 @@ namespace net = boost::asio; #define BOOST_BEAST_INLINE_VARIABLE(name, type) \ inline namespace \ { \ - constexpr auto &name = \ + constexpr auto& name = \ ::boost::beast::detail::static_const::value; \ } diff --git a/include/boost/beast/core/impl/buffers_adaptor.hpp b/include/boost/beast/core/impl/buffers_adaptor.hpp index 652d936b..adac3e2b 100644 --- a/include/boost/beast/core/impl/buffers_adaptor.hpp +++ b/include/boost/beast/core/impl/buffers_adaptor.hpp @@ -10,6 +10,7 @@ #ifndef BOOST_BEAST_IMPL_BUFFERS_ADAPTOR_HPP #define BOOST_BEAST_IMPL_BUFFERS_ADAPTOR_HPP +#include #include #include #include @@ -400,7 +401,6 @@ buffers_adaptor(MutableBufferSequence const& bs) , max_size_( [&bs] { - using net::buffer_size; return buffer_size(bs); }()) { @@ -418,7 +418,6 @@ buffers_adaptor( , max_size_( [&] { - using net::buffer_size; return buffer_size(bs_); }()) { @@ -502,7 +501,6 @@ prepare(std::size_t n) -> end_ = out_; if(end_ != net::buffer_sequence_end(bs_)) { - using net::buffer_size; auto size = buffer_size(*end_) - out_pos_; if(n > size) { @@ -545,7 +543,6 @@ commit(std::size_t n) noexcept auto const last = std::prev(end_); while(out_ != last) { - using net::buffer_size; auto const avail = buffer_size(*out_) - out_pos_; if(n < avail) @@ -579,7 +576,6 @@ consume(std::size_t n) noexcept { while(begin_ != out_) { - using net::buffer_size; auto const avail = buffer_size(*begin_) - in_pos_; if(n < avail) diff --git a/include/boost/beast/core/impl/buffers_prefix.hpp b/include/boost/beast/core/impl/buffers_prefix.hpp index 41340e58..a58a999d 100644 --- a/include/boost/beast/core/impl/buffers_prefix.hpp +++ b/include/boost/beast/core/impl/buffers_prefix.hpp @@ -10,6 +10,7 @@ #ifndef BOOST_BEAST_IMPL_BUFFERS_PREFIX_HPP #define BOOST_BEAST_IMPL_BUFFERS_PREFIX_HPP +#include #include #include #include @@ -149,7 +150,6 @@ setup(std::size_t size) auto const last = bs_.end(); while(end_ != last) { - using net::buffer_size; auto const len = buffer_size(*end_++); if(len >= size) { @@ -248,14 +248,6 @@ end() const -> *this, std::true_type{}}; } -template -std::size_t -buffer_size(buffers_prefix_view< - Buffers> const& buffers) -{ - return buffers.size_; -} - //------------------------------------------------------------------------------ template<> @@ -290,14 +282,13 @@ public: std::forward(args)...)) { } -}; -std::size_t -buffer_size(buffers_prefix_view< - net::const_buffer> const& buffers) -{ - return buffers.size(); -} + std::size_t + buffer_size_impl() const noexcept + { + return this->size(); + } +}; //------------------------------------------------------------------------------ @@ -333,14 +324,13 @@ public: std::forward(args)...)) { } -}; -std::size_t -buffer_size(buffers_prefix_view< - net::mutable_buffer> const& buffers) -{ - return buffers.size(); -} + std::size_t + buffer_size_impl() const noexcept + { + return this->size(); + } +}; } // beast } // boost diff --git a/include/boost/beast/core/impl/buffers_suffix.hpp b/include/boost/beast/core/impl/buffers_suffix.hpp index f7e037f6..8f6775a3 100644 --- a/include/boost/beast/core/impl/buffers_suffix.hpp +++ b/include/boost/beast/core/impl/buffers_suffix.hpp @@ -10,6 +10,7 @@ #ifndef BOOST_BEAST_IMPL_BUFFERS_SUFFIX_HPP #define BOOST_BEAST_IMPL_BUFFERS_SUFFIX_HPP +#include #include #include #include @@ -206,7 +207,6 @@ consume(std::size_t amount) net::buffer_sequence_end(bs_); for(;amount > 0 && begin_ != end; ++begin_) { - using net::buffer_size; auto const len = buffer_size(*begin_) - skip_; if(amount < len) diff --git a/include/boost/beast/core/impl/multi_buffer.hpp b/include/boost/beast/core/impl/multi_buffer.hpp index 6f119702..4b9bc5fc 100644 --- a/include/boost/beast/core/impl/multi_buffer.hpp +++ b/include/boost/beast/core/impl/multi_buffer.hpp @@ -10,6 +10,7 @@ #ifndef BOOST_BEAST_IMPL_MULTI_BUFFER_HPP #define BOOST_BEAST_IMPL_MULTI_BUFFER_HPP +#include #include #include #include @@ -195,11 +196,10 @@ public: const_iterator begin() const noexcept; const_iterator end() const noexcept; - friend std::size_t - buffer_size(readable_bytes const& buffers) noexcept + buffer_size() const noexcept { - return buffers.b_->size(); + return b_->size(); } }; @@ -1132,7 +1132,6 @@ basic_multi_buffer:: debug_check() const { #ifndef NDEBUG - using net::buffer_size; BOOST_ASSERT(buffer_size(data()) == in_size_); if(list_.empty()) { diff --git a/include/boost/beast/core/make_printable.hpp b/include/boost/beast/core/make_printable.hpp index f3eaa4c3..ea9fa9cb 100644 --- a/include/boost/beast/core/make_printable.hpp +++ b/include/boost/beast/core/make_printable.hpp @@ -11,6 +11,7 @@ #define BOOST_BEAST_MAKE_PRINTABLE_HPP #include +#include #include #include @@ -73,7 +74,6 @@ operator<<(std::ostream& os, void print (ConstBufferSequence const& buffers) { - using net::buffer_size; std::cout << "Buffer size: " << buffer_size(buffers) << " bytes\n" "Buffer data: '" << make_printable(buffers) << "'\n"; diff --git a/include/boost/beast/http/basic_dynamic_body.hpp b/include/boost/beast/http/basic_dynamic_body.hpp index 66254710..aeda738e 100644 --- a/include/boost/beast/http/basic_dynamic_body.hpp +++ b/include/boost/beast/http/basic_dynamic_body.hpp @@ -11,6 +11,7 @@ #define BOOST_BEAST_HTTP_BASIC_DYNAMIC_BODY_HPP #include +#include #include #include #include @@ -88,7 +89,6 @@ struct basic_dynamic_body put(ConstBufferSequence const& buffers, error_code& ec) { - using net::buffer_size; auto const n = buffer_size(buffers); if(body_.size() > body_.max_size() - n) { diff --git a/include/boost/beast/http/buffer_body.hpp b/include/boost/beast/http/buffer_body.hpp index 57cf43e2..f0f660ce 100644 --- a/include/boost/beast/http/buffer_body.hpp +++ b/include/boost/beast/http/buffer_body.hpp @@ -11,6 +11,7 @@ #define BOOST_BEAST_HTTP_BUFFER_BODY_HPP #include +#include #include #include #include @@ -132,7 +133,6 @@ struct buffer_body body_.data = static_cast( body_.data) + bytes_transferred; body_.size -= bytes_transferred; - using net::buffer_size; if(bytes_transferred == buffer_size(buffers)) ec = {}; else diff --git a/include/boost/beast/http/impl/basic_parser.ipp b/include/boost/beast/http/impl/basic_parser.ipp index 337bc8e8..bd57fcbc 100644 --- a/include/boost/beast/http/impl/basic_parser.ipp +++ b/include/boost/beast/http/impl/basic_parser.ipp @@ -10,6 +10,7 @@ #ifndef BOOST_BEAST_HTTP_IMPL_BASIC_PARSER_IPP #define BOOST_BEAST_HTTP_IMPL_BASIC_PARSER_IPP +#include #include #include #include @@ -106,7 +107,6 @@ put(ConstBufferSequence const& buffers, // single buffer return put(net::const_buffer(*p), ec); } - using net::buffer_size; auto const size = buffer_size(buffers); if(size <= max_stack_buffer) return put_from_stack(size, buffers, ec); @@ -130,7 +130,6 @@ put(net::const_buffer const& buffer, error_code& ec) { BOOST_ASSERT(state_ != state::complete); - using net::buffer_size; auto p = static_cast(buffer.data()); auto n = buffer.size(); auto const p0 = p; diff --git a/include/boost/beast/http/impl/chunk_encode.ipp b/include/boost/beast/http/impl/chunk_encode.ipp index 03a9b85a..89ce2511 100644 --- a/include/boost/beast/http/impl/chunk_encode.ipp +++ b/include/boost/beast/http/impl/chunk_encode.ipp @@ -10,6 +10,7 @@ #ifndef BOOST_BEAST_HTTP_IMPL_CHUNK_ENCODE_IPP #define BOOST_BEAST_HTTP_IMPL_CHUNK_ENCODE_IPP +#include #include #include #include @@ -89,11 +90,7 @@ template chunk_body:: chunk_body(ConstBufferSequence const& buffers) : view_( - [&] - { - using net::buffer_size; - return buffer_size(buffers); - }(), + buffer_size(buffers), net::const_buffer{nullptr, 0}, chunk_crlf{}, buffers, @@ -107,11 +104,7 @@ chunk_body( ConstBufferSequence const& buffers, string_view extensions) : view_( - [&] - { - using net::buffer_size; - return buffer_size(buffers); - }(), + buffer_size(buffers), net::const_buffer{ extensions.data(), extensions.size()}, chunk_crlf{}, @@ -130,11 +123,7 @@ chunk_body( typename std::decay::type>>( std::forward(extensions))) , view_( - [&] - { - using net::buffer_size; - return buffer_size(buffers); - }(), + buffer_size(buffers), exts_->str(), chunk_crlf{}, buffers, @@ -153,11 +142,7 @@ chunk_body( typename std::decay::type>>(allocator, std::forward(extensions))) , view_( - [&] - { - using net::buffer_size; - return buffer_size(buffers); - }(), + buffer_size(buffers), exts_->str(), chunk_crlf{}, buffers, diff --git a/include/boost/beast/http/impl/serializer.ipp b/include/boost/beast/http/impl/serializer.ipp index ccad3d9e..77ec2184 100644 --- a/include/boost/beast/http/impl/serializer.ipp +++ b/include/boost/beast/http/impl/serializer.ipp @@ -10,6 +10,7 @@ #ifndef BOOST_BEAST_HTTP_IMPL_SERIALIZER_IPP #define BOOST_BEAST_HTTP_IMPL_SERIALIZER_IPP +#include #include #include #include @@ -70,7 +71,6 @@ void serializer:: next(error_code& ec, Visit&& visit) { - using net::buffer_size; switch(s_) { case do_construct: @@ -289,7 +289,6 @@ void serializer:: consume(std::size_t n) { - using net::buffer_size; switch(s_) { case do_header: diff --git a/include/boost/beast/http/span_body.hpp b/include/boost/beast/http/span_body.hpp index 6e691054..8f02c473 100644 --- a/include/boost/beast/http/span_body.hpp +++ b/include/boost/beast/http/span_body.hpp @@ -11,6 +11,7 @@ #define BOOST_BEAST_HTTP_SPAN_BODY_HPP #include +#include #include #include #include @@ -95,7 +96,6 @@ public: put(ConstBufferSequence const& buffers, error_code& ec) { - using net::buffer_size; auto const n = buffer_size(buffers); auto const len = body_.size(); if(n > len) diff --git a/include/boost/beast/http/string_body.hpp b/include/boost/beast/http/string_body.hpp index 00173ac2..d51ed617 100644 --- a/include/boost/beast/http/string_body.hpp +++ b/include/boost/beast/http/string_body.hpp @@ -11,6 +11,7 @@ #define BOOST_BEAST_HTTP_STRING_BODY_HPP #include +#include #include #include #include @@ -117,7 +118,6 @@ public: put(ConstBufferSequence const& buffers, error_code& ec) { - using net::buffer_size; auto const extra = buffer_size(buffers); auto const size = body_.size(); try diff --git a/include/boost/beast/http/vector_body.hpp b/include/boost/beast/http/vector_body.hpp index a1b35610..9005a30a 100644 --- a/include/boost/beast/http/vector_body.hpp +++ b/include/boost/beast/http/vector_body.hpp @@ -11,6 +11,7 @@ #define BOOST_BEAST_HTTP_VECTOR_BODY_HPP #include +#include #include #include #include @@ -111,7 +112,6 @@ public: put(ConstBufferSequence const& buffers, error_code& ec) { - using net::buffer_size; auto const n = buffer_size(buffers); auto const len = body_.size(); try diff --git a/include/boost/beast/websocket/detail/frame.hpp b/include/boost/beast/websocket/detail/frame.hpp index c05c7318..d4f695f4 100644 --- a/include/boost/beast/websocket/detail/frame.hpp +++ b/include/boost/beast/websocket/detail/frame.hpp @@ -10,6 +10,7 @@ #ifndef BOOST_BEAST_WEBSOCKET_DETAIL_FRAME_HPP #define BOOST_BEAST_WEBSOCKET_DETAIL_FRAME_HPP +#include #include #include #include @@ -229,7 +230,6 @@ template void read_ping(ping_data& data, Buffers const& bs) { - using net::buffer_size; BOOST_ASSERT(buffer_size(bs) <= data.max_size()); data.resize(buffer_size(bs)); net::buffer_copy(net::mutable_buffer{ @@ -246,9 +246,7 @@ read_close( Buffers const& bs, error_code& ec) { - using net::buffer; using namespace boost::endian; - using net::buffer_size; auto n = buffer_size(bs); BOOST_ASSERT(n <= 125); if(n == 0) @@ -266,7 +264,7 @@ read_close( buffers_suffix cb(bs); { std::uint8_t b[2]; - net::buffer_copy(buffer(b), cb); + net::buffer_copy(net::buffer(b), cb); cr.code = big_uint16_to_native(&b[0]); cb.consume(2); n -= 2; @@ -280,7 +278,8 @@ read_close( if(n > 0) { cr.reason.resize(n); - net::buffer_copy(buffer(&cr.reason[0], n), cb); + net::buffer_copy( + net::buffer(&cr.reason[0], n), cb); if(! check_utf8( cr.reason.data(), cr.reason.size())) { diff --git a/include/boost/beast/websocket/detail/stream_base.hpp b/include/boost/beast/websocket/detail/stream_base.hpp index a072d845..a14f69bc 100644 --- a/include/boost/beast/websocket/detail/stream_base.hpp +++ b/include/boost/beast/websocket/detail/stream_base.hpp @@ -10,6 +10,7 @@ #ifndef BOOST_BEAST_WEBSOCKET_DETAIL_STREAM_BASE_HPP #define BOOST_BEAST_WEBSOCKET_DETAIL_STREAM_BASE_HPP +#include #include #include #include @@ -88,7 +89,6 @@ struct impl_base std::size_t& total_in, error_code& ec) { - using net::buffer; BOOST_ASSERT(out.size() >= 6); auto& zo = this->pmd_->zo; zlib::z_params zs; @@ -123,7 +123,6 @@ struct impl_base cb.consume(zs.total_in); if(zs.avail_out > 0 && fin) { - using net::buffer_size; auto const remain = buffer_size(cb); if(remain == 0) { @@ -144,13 +143,13 @@ struct impl_base BOOST_ASSERT(! ec); // remove flush marker zs.total_out -= 4; - out = buffer(out.data(), zs.total_out); + out = net::buffer(out.data(), zs.total_out); return false; } } } ec = {}; - out = buffer(out.data(), zs.total_out); + out = net::buffer(out.data(), zs.total_out); return true; } diff --git a/include/boost/beast/websocket/impl/accept.hpp b/include/boost/beast/websocket/impl/accept.hpp index 44a014af..9eabf5d2 100644 --- a/include/boost/beast/websocket/impl/accept.hpp +++ b/include/boost/beast/websocket/impl/accept.hpp @@ -10,6 +10,7 @@ #ifndef BOOST_BEAST_WEBSOCKET_IMPL_ACCEPT_IPP #define BOOST_BEAST_WEBSOCKET_IMPL_ACCEPT_IPP +#include #include #include #include @@ -122,7 +123,6 @@ public: void run(Buffers const& buffers) { error_code ec; - using net::buffer_size; auto const mb = beast::detail::dynamic_buffer_prepare( ws_.impl_->rd_buf, buffer_size(buffers), ec, error::buffer_overflow); @@ -296,7 +296,6 @@ accept( ConstBufferSequence>::value, "ConstBufferSequence requirements not met"); impl_->reset(); - using net::buffer_size; auto const mb = beast::detail::dynamic_buffer_prepare( impl_->rd_buf, buffer_size(buffers), ec, error::buffer_overflow); @@ -327,7 +326,6 @@ accept_ex( ConstBufferSequence>::value, "ConstBufferSequence requirements not met"); impl_->reset(); - using net::buffer_size; auto const mb = beast::detail::dynamic_buffer_prepare( impl_->rd_buf, buffer_size(buffers), ec, error::buffer_overflow); diff --git a/include/boost/beast/websocket/impl/read.hpp b/include/boost/beast/websocket/impl/read.hpp index f6742826..c5f55b85 100644 --- a/include/boost/beast/websocket/impl/read.hpp +++ b/include/boost/beast/websocket/impl/read.hpp @@ -10,6 +10,7 @@ #ifndef BOOST_BEAST_WEBSOCKET_IMPL_READ_HPP #define BOOST_BEAST_WEBSOCKET_IMPL_READ_HPP +#include #include #include #include @@ -82,8 +83,6 @@ public: bool cont = true) { using beast::detail::clamp; - using net::buffer; - using net::buffer_size; auto& impl = *ws_.impl_; cont_ = cont; BOOST_ASIO_CORO_REENTER(*this) @@ -881,8 +880,6 @@ read_some( MutableBufferSequence>::value, "MutableBufferSequence requirements not met"); using beast::detail::clamp; - using net::buffer; - using net::buffer_size; close_code code{}; std::size_t bytes_written = 0; ec = {}; diff --git a/include/boost/beast/websocket/impl/stream.hpp b/include/boost/beast/websocket/impl/stream.hpp index 7f8a14e0..2fa96914 100644 --- a/include/boost/beast/websocket/impl/stream.hpp +++ b/include/boost/beast/websocket/impl/stream.hpp @@ -10,6 +10,7 @@ #ifndef BOOST_BEAST_WEBSOCKET_IMPL_STREAM_HPP #define BOOST_BEAST_WEBSOCKET_IMPL_STREAM_HPP +#include #include #include #include @@ -282,7 +283,6 @@ parse_fh( DynamicBuffer& b, error_code& ec) { - using net::buffer_size; if(buffer_size(b.data()) < 2) { // need more bytes diff --git a/include/boost/beast/websocket/impl/teardown.hpp b/include/boost/beast/websocket/impl/teardown.hpp index 6e627d4c..c01aecd7 100644 --- a/include/boost/beast/websocket/impl/teardown.hpp +++ b/include/boost/beast/websocket/impl/teardown.hpp @@ -57,7 +57,6 @@ public: error_code ec = {}, std::size_t bytes_transferred = 0) { - using net::buffer; using tcp = net::ip::tcp; BOOST_ASIO_CORO_REENTER(*this) { @@ -130,7 +129,6 @@ teardown( net::ip::tcp::socket& socket, error_code& ec) { - using net::buffer; if(role == role_type::server) socket.shutdown( net::ip::tcp::socket::shutdown_send, ec); @@ -140,7 +138,7 @@ teardown( { char buf[2048]; auto const bytes_transferred = - socket.read_some(buffer(buf), ec); + socket.read_some(net::buffer(buf), ec); if(ec) { if(ec != net::error::eof) diff --git a/include/boost/beast/websocket/impl/write.hpp b/include/boost/beast/websocket/impl/write.hpp index 0a289351..8c3da28c 100644 --- a/include/boost/beast/websocket/impl/write.hpp +++ b/include/boost/beast/websocket/impl/write.hpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -88,7 +89,6 @@ operator()( bool cont) { using beast::detail::clamp; - using net::buffer_size; enum { do_nomask_nofrag, @@ -470,7 +470,6 @@ write_some(bool fin, ConstBufferSequence>::value, "ConstBufferSequence requirements not met"); using beast::detail::clamp; - using net::buffer_size; std::size_t bytes_transferred = 0; ec = {}; // Make sure the stream is open diff --git a/test/beast/core/CMakeLists.txt b/test/beast/core/CMakeLists.txt index 72ee830f..4e15788e 100644 --- a/test/beast/core/CMakeLists.txt +++ b/test/beast/core/CMakeLists.txt @@ -31,6 +31,7 @@ add_executable (tests-beast-core async_op_base.cpp basic_timeout_stream.cpp bind_handler.cpp + buffer_size.cpp buffer_traits.cpp buffered_read_stream.cpp buffers_adapter.cpp diff --git a/test/beast/core/Jamfile b/test/beast/core/Jamfile index ebbb8d53..7cff93d5 100644 --- a/test/beast/core/Jamfile +++ b/test/beast/core/Jamfile @@ -19,6 +19,7 @@ local SOURCES = async_op_base.cpp basic_timeout_stream.cpp bind_handler.cpp + buffer_size.cpp buffer_traits.cpp buffered_read_stream.cpp buffers_adapter.cpp diff --git a/test/beast/core/buffer_size.cpp b/test/beast/core/buffer_size.cpp new file mode 100644 index 00000000..812b59eb --- /dev/null +++ b/test/beast/core/buffer_size.cpp @@ -0,0 +1,98 @@ +// +// 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 +// + +// Test that header file is self-contained. +#include + +#include +#include + +namespace boost { +namespace beast { + +namespace { + +struct sequence +{ + struct value_type + { + operator net::const_buffer() const noexcept + { + return {"Hello, world!", 13}; + } + }; + + using const_iterator = value_type const*; + + const_iterator begin() const noexcept + { + return &v_; + } + + const_iterator end() const noexcept + { + return begin() + 1; + } + +private: + value_type v_; +}; + +struct not_sequence +{ +}; + +} // (anon) + +class buffer_size_test : public beast::unit_test::suite +{ +public: + void + testJavadocs() + { + pass(); + } + + void + testFunction() + { + BEAST_EXPECT(buffer_size( + net::const_buffer("Hello, world!", 13)) == 13); + + BEAST_EXPECT(buffer_size( + net::mutable_buffer{}) == 0); + + { + sequence s; + BEAST_EXPECT(buffer_size(s) == 13); + } + + { + std::array s({{ + net::const_buffer("Hello, world!", 13), + net::const_buffer("Hello, world!", 13)}}); + BEAST_EXPECT(buffer_size(s) == 26); + } + + BOOST_STATIC_ASSERT(! detail::is_invocable< + detail::buffer_size_impl, + std::size_t(not_sequence const&)>::value); + } + + void run() override + { + testFunction(); + testJavadocs(); + } +}; + +BEAST_DEFINE_TESTSUITE(beast,core,buffer_size); + +} // beast +} // boost diff --git a/test/beast/core/buffer_test.hpp b/test/beast/core/buffer_test.hpp index d1a35d48..f2378145 100644 --- a/test/beast/core/buffer_test.hpp +++ b/test/beast/core/buffer_test.hpp @@ -12,6 +12,7 @@ #include #include +#include #include #include #include @@ -116,7 +117,6 @@ void test_mutable_buffers( MutableBufferSequence const& b, net::mutable_buffer) { - using net::buffer_size; string_view src = "Hello, world!"; BOOST_ASSERT(buffer_size(b) <= src.size()); if(src.size() > buffer_size(b)) @@ -139,8 +139,6 @@ test_buffer_sequence( net::is_const_buffer_sequence< ConstBufferSequence>::value); - using net::buffer_size; - using iterator = decltype( net::buffer_sequence_begin(buffers)); BEAST_EXPECT(sizeof(iterator) > 0); @@ -183,7 +181,6 @@ test_buffer_sequence( // bidirectional { - using net::buffer_size; auto const first = net::buffer_sequence_begin(buffers); auto const last = @@ -290,8 +287,6 @@ test_mutable_dynamic_buffer( MutableDynamicBuffer const& b0, std::true_type) { - using net::buffer_size; - BOOST_STATIC_ASSERT( net::is_mutable_buffer_sequence::value); @@ -372,8 +367,6 @@ void test_dynamic_buffer( DynamicBuffer const& b0) { - using net::buffer_size; - BOOST_STATIC_ASSERT( net::is_dynamic_buffer::value); diff --git a/test/beast/core/buffered_read_stream.cpp b/test/beast/core/buffered_read_stream.cpp index 338bfe46..d08413ae 100644 --- a/test/beast/core/buffered_read_stream.cpp +++ b/test/beast/core/buffered_read_stream.cpp @@ -80,7 +80,6 @@ public: void on_read(error_code ec, std::size_t) { - using net::buffer; if(! ec) { suite_.expect(s_ == diff --git a/test/beast/core/buffers_adaptor.cpp b/test/beast/core/buffers_adaptor.cpp index 055dfb90..9ecd8c04 100644 --- a/test/beast/core/buffers_adaptor.cpp +++ b/test/beast/core/buffers_adaptor.cpp @@ -12,6 +12,7 @@ #include "buffer_test.hpp" +#include #include #include #include @@ -42,8 +43,6 @@ public: void testSpecial() { - using net::buffer_size; - char s1[13]; buffers_triple tb1(s1, sizeof(s1)); BEAST_EXPECT(buffer_size(tb1) == sizeof(s1)); diff --git a/test/beast/core/buffers_cat.cpp b/test/beast/core/buffers_cat.cpp index c36c02a2..f660d8fe 100644 --- a/test/beast/core/buffers_cat.cpp +++ b/test/beast/core/buffers_cat.cpp @@ -13,6 +13,7 @@ #include "buffer_test.hpp" #include +#include #include #include #include @@ -155,8 +156,6 @@ public: void testEmpty() { - using net::buffer_size; - struct empty_sequence { using value_type = net::const_buffer; @@ -275,19 +274,14 @@ public: void testGccWarning1() { - using boost::beast::buffers_cat; - using boost::beast::buffers_suffix; - using net::buffer; - using net::const_buffer; - char out[64]; - std::array buffers{ - {buffer("Hello, "), buffer("world!")}}; + std::array buffers{ + {net::buffer("Hello, "), net::buffer("world!")}}; std::size_t i = 3; - buffers_suffix> cb(buffers); + buffers_suffix> cb(buffers); cb.consume(i); net::buffer_copy( - buffer(out), + net::buffer(out), buffers_cat(cb, cb)); } diff --git a/test/beast/core/buffers_prefix.cpp b/test/beast/core/buffers_prefix.cpp index 1a76064c..bc2b655f 100644 --- a/test/beast/core/buffers_prefix.cpp +++ b/test/beast/core/buffers_prefix.cpp @@ -12,6 +12,7 @@ #include "buffer_test.hpp" +#include #include #include #include @@ -89,7 +90,6 @@ public: void testPrefixes() { - using net::buffer_size; std::string s = "Hello, world"; BEAST_EXPECT(s.size() == 12); for(std::size_t x = 1; x < 4; ++x) { @@ -118,8 +118,6 @@ public: void testEmpty() { - using net::buffer_size; - auto pb0 = buffers_prefix(0, net::mutable_buffer{}); BEAST_EXPECT(buffer_size(pb0) == 0); auto pb1 = buffers_prefix(1, net::mutable_buffer{}); diff --git a/test/beast/core/buffers_suffix.cpp b/test/beast/core/buffers_suffix.cpp index 5a7fa522..de08a968 100644 --- a/test/beast/core/buffers_suffix.cpp +++ b/test/beast/core/buffers_suffix.cpp @@ -12,6 +12,7 @@ #include "buffer_test.hpp" +#include #include #include #include @@ -80,7 +81,6 @@ public: // empty sequence { - using net::buffer_size; buffers_suffix cb( net::mutable_buffer{}); BEAST_EXPECT(buffer_size(cb) == 0); @@ -113,7 +113,6 @@ public: void testMatrix() { - using net::buffer_size; char buf[12]; std::string const s = "Hello, world"; BEAST_EXPECT(s.size() == sizeof(buf)); diff --git a/test/beast/core/flat_static_buffer.cpp b/test/beast/core/flat_static_buffer.cpp index b97817c0..2995fe24 100644 --- a/test/beast/core/flat_static_buffer.cpp +++ b/test/beast/core/flat_static_buffer.cpp @@ -12,6 +12,7 @@ #include "buffer_test.hpp" +#include #include #include #include @@ -40,8 +41,6 @@ public: void testMembers() { - using net::buffer_size; - string_view const s = "Hello, world!"; // flat_static_buffer_base diff --git a/test/beast/core/make_printable.cpp b/test/beast/core/make_printable.cpp index 002cd2b8..55160da6 100644 --- a/test/beast/core/make_printable.cpp +++ b/test/beast/core/make_printable.cpp @@ -9,7 +9,9 @@ // Test that header file is self-contained. #include + #include +#include #include #include @@ -25,7 +27,6 @@ public: void print (ConstBufferSequence const& buffers) { - using net::buffer_size; std::cout << "Buffer size: " << buffer_size(buffers) << " bytes\n" "Buffer data: '" << make_printable(buffers) << "'\n"; @@ -40,8 +41,6 @@ public: void testMakePrintable() { - using net::buffer; - char buf[13]; buffers_triple b(buf, sizeof(buf)); string_view src = "Hello, world!"; diff --git a/test/beast/core/multi_buffer.cpp b/test/beast/core/multi_buffer.cpp index 5ec5a918..93b92cf3 100644 --- a/test/beast/core/multi_buffer.cpp +++ b/test/beast/core/multi_buffer.cpp @@ -12,6 +12,7 @@ #include "buffer_test.hpp" +#include #include #include #include @@ -577,8 +578,6 @@ public: void testMatrix1() { - using net::buffer_size; - string_view s = "Hello, world"; BEAST_EXPECT(s.size() == 12); for(std::size_t i = 1; i < 12; ++i) { @@ -621,8 +620,6 @@ public: testMatrix2() { using namespace test; - using net::buffer; - using net::buffer_size; std::string const s = "Hello, world"; BEAST_EXPECT(s.size() == 12); for(std::size_t i = 1; i < 12; ++i) { @@ -649,7 +646,7 @@ public: { auto d = b.prepare(x); BEAST_EXPECT(buffer_size(d) == x); - b.commit(buffer_copy(d, buffer(s.data(), x))); + b.commit(buffer_copy(d, net::buffer(s.data(), x))); } BEAST_EXPECT(b.size() == x); BEAST_EXPECT(buffer_size(b.data()) == b.size()); @@ -668,7 +665,7 @@ public: { auto d = b.prepare(y); BEAST_EXPECT(buffer_size(d) == y); - b.commit(buffer_copy(d, buffer(s.data()+x, y))); + b.commit(buffer_copy(d, net::buffer(s.data()+x, y))); } b.commit(1); BEAST_EXPECT(b.size() == x + y); @@ -688,7 +685,7 @@ public: { auto d = b.prepare(z); BEAST_EXPECT(buffer_size(d) == z); - b.commit(buffer_copy(d, buffer(s.data()+x+y, z))); + b.commit(buffer_copy(d, net::buffer(s.data()+x+y, z))); } b.commit(2); BEAST_EXPECT(b.size() == x + y + z); diff --git a/test/beast/core/static_buffer.cpp b/test/beast/core/static_buffer.cpp index afbd2ad4..d5033fc8 100644 --- a/test/beast/core/static_buffer.cpp +++ b/test/beast/core/static_buffer.cpp @@ -12,6 +12,7 @@ #include "buffer_test.hpp" +#include #include #include #include @@ -44,8 +45,6 @@ public: void testMembers() { - using net::buffer_size; - string_view const s = "Hello, world!"; // static_buffer_base diff --git a/test/beast/http/basic_parser.cpp b/test/beast/http/basic_parser.cpp index 79a5cd80..cd2b4fac 100644 --- a/test/beast/http/basic_parser.cpp +++ b/test/beast/http/basic_parser.cpp @@ -13,6 +13,7 @@ #include "message_fuzz.hpp" #include "test_parser.hpp" +#include #include #include #include @@ -156,7 +157,6 @@ public: parsegrind(ConstBufferSequence const& buffers, Test const& test, bool skip = false) { - using net::buffer_size; auto const size = buffer_size(buffers); for(std::size_t i = 1; i < size - 1; ++i) { diff --git a/test/beast/http/file_body.cpp b/test/beast/http/file_body.cpp index dc9e1c46..5a981697 100644 --- a/test/beast/http/file_body.cpp +++ b/test/beast/http/file_body.cpp @@ -10,6 +10,7 @@ // Test that header file is self-contained. #include +#include #include #include #include @@ -33,7 +34,6 @@ public: void operator()(error_code&, ConstBufferSequence const& buffers) { - using net::buffer_size; buffer.commit(net::buffer_copy( buffer.prepare(buffer_size(buffers)), buffers)); diff --git a/test/beast/http/parser.cpp b/test/beast/http/parser.cpp index 43c7a669..943a97bb 100644 --- a/test/beast/http/parser.cpp +++ b/test/beast/http/parser.cpp @@ -14,6 +14,7 @@ #include #include +#include #include #include #include @@ -51,7 +52,6 @@ public: basic_parser& p, error_code& ec) { - using net::buffer_size; buffers_suffix cb{buffers}; for(;;) { @@ -75,13 +75,12 @@ public: void doMatrix(string_view s0, F const& f) { - using net::buffer; // parse a single buffer { auto s = s0; error_code ec; parser_type p; - put(buffer(s.data(), s.size()), p, ec); + put(net::buffer(s.data(), s.size()), p, ec); if(! BEAST_EXPECTS(! ec, ec.message())) return; f(p); @@ -94,7 +93,7 @@ public: parser_type p; p.eager(true); auto used = - p.put(buffer(s.data(), n), ec); + p.put(net::buffer(s.data(), n), ec); s.remove_prefix(used); if(ec == error::need_more) ec = {}; @@ -102,7 +101,7 @@ public: continue; BEAST_EXPECT(! p.is_done()); used = p.put( - buffer(s.data(), s.size()), ec); + net::buffer(s.data(), s.size()), ec); s.remove_prefix(used); if(! BEAST_EXPECTS(! ec, ec.message())) continue; diff --git a/test/beast/http/read.cpp b/test/beast/http/read.cpp index 2b3754eb..2815d744 100644 --- a/test/beast/http/read.cpp +++ b/test/beast/http/read.cpp @@ -430,7 +430,6 @@ public: void readgrind(string_view s, Pred&& pred) { - using net::buffer; for(std::size_t n = 1; n < s.size() - 1; ++n) { Parser p; diff --git a/test/beast/http/serializer.cpp b/test/beast/http/serializer.cpp index b9bc2aae..ea68f55d 100644 --- a/test/beast/http/serializer.cpp +++ b/test/beast/http/serializer.cpp @@ -10,6 +10,7 @@ // Test that header file is self-contained. #include +#include #include #include @@ -91,7 +92,6 @@ public: operator()(error_code&, ConstBufferSequence const& buffers) { - using net::buffer_size; size = buffer_size(buffers); } }; diff --git a/test/beast/http/span_body.cpp b/test/beast/http/span_body.cpp index 12c8db3d..99b7323d 100644 --- a/test/beast/http/span_body.cpp +++ b/test/beast/http/span_body.cpp @@ -10,6 +10,7 @@ // Test that header file is self-contained. #include +#include #include #include @@ -23,7 +24,6 @@ struct span_body_test void testSpanBody() { - using net::buffer_size; { using B = span_body; request req; diff --git a/test/beast/http/write.cpp b/test/beast/http/write.cpp index 83471356..cdc11420 100644 --- a/test/beast/http/write.cpp +++ b/test/beast/http/write.cpp @@ -124,10 +124,10 @@ public: std::false_type, // isSplit std::false_type) // isFinalEmpty { - using net::buffer; if(body_.s.empty()) return boost::none; - return {{buffer(body_.s.data(), body_.s.size()), false}}; + return {{net::buffer( + body_.s.data(), body_.s.size()), false}}; } boost::optional> @@ -135,14 +135,13 @@ public: std::false_type, // isSplit std::true_type) // isFinalEmpty { - using net::buffer; if(body_.s.empty()) return boost::none; switch(step_) { case 0: step_ = 1; - return {{buffer( + return {{net::buffer( body_.s.data(), body_.s.size()), true}}; default: return boost::none; @@ -154,7 +153,6 @@ public: std::true_type, // isSplit std::false_type) // isFinalEmpty { - using net::buffer; auto const n = (body_.s.size() + 1) / 2; switch(step_) { @@ -162,10 +160,10 @@ public: if(n == 0) return boost::none; step_ = 1; - return {{buffer(body_.s.data(), n), + return {{net::buffer(body_.s.data(), n), body_.s.size() > 1}}; default: - return {{buffer(body_.s.data() + n, + return {{net::buffer(body_.s.data() + n, body_.s.size() - n), false}}; } } @@ -175,7 +173,6 @@ public: std::true_type, // isSplit std::true_type) // isFinalEmpty { - using net::buffer; auto const n = (body_.s.size() + 1) / 2; switch(step_) { @@ -183,11 +180,11 @@ public: if(n == 0) return boost::none; step_ = body_.s.size() > 1 ? 1 : 2; - return {{buffer(body_.s.data(), n), true}}; + return {{net::buffer(body_.s.data(), n), true}}; case 1: BOOST_ASSERT(body_.s.size() > 1); step_ = 2; - return {{buffer(body_.s.data() + n, + return {{net::buffer(body_.s.data() + n, body_.s.size() - n), true}}; default: return boost::none; diff --git a/test/beast/websocket/close.cpp b/test/beast/websocket/close.cpp index ee488164..44474dcd 100644 --- a/test/beast/websocket/close.cpp +++ b/test/beast/websocket/close.cpp @@ -171,8 +171,6 @@ public: void testSuspend() { - using net::buffer; - // suspend on ping doFailLoop([&](test::fail_count& fc) { @@ -374,7 +372,7 @@ public: "\x88\x00", 2}); std::size_t count = 0; std::string const s = "Hello, world!"; - ws.async_write(buffer(s), + ws.async_write(net::buffer(s), [&](error_code ec, std::size_t n) { if(ec) @@ -419,7 +417,7 @@ public: std::size_t count = 0; multi_buffer b; std::string const s = "Hello, world!"; - ws.async_write(buffer(s), + ws.async_write(net::buffer(s), [&](error_code ec, std::size_t n) { if(ec) @@ -479,7 +477,7 @@ public: system_error{ec}); ++count; }); - ws.async_write(buffer(s), + ws.async_write(net::buffer(s), [&](error_code ec, std::size_t) { if(ec != net::error::operation_aborted) @@ -527,7 +525,7 @@ public: BEAST_EXPECT( ec == net::error::operation_aborted); }); - ws.async_write(buffer(s), + ws.async_write(net::buffer(s), [&](error_code ec, std::size_t n) { if(ec) @@ -588,7 +586,7 @@ public: system_error{ec}); ++count; }); - ws.async_write(buffer(s), + ws.async_write(net::buffer(s), [&](error_code ec, std::size_t) { if(ec != net::error::operation_aborted) diff --git a/test/beast/websocket/read1.cpp b/test/beast/websocket/read1.cpp index 9684ef40..6f279dae 100644 --- a/test/beast/websocket/read1.cpp +++ b/test/beast/websocket/read1.cpp @@ -75,8 +75,6 @@ public: void doTestRead(Wrap const& w) { - using net::buffer; - permessage_deflate pmd; pmd.client_enable = false; pmd.server_enable = false; @@ -230,7 +228,7 @@ public: std::string const s(2000, '*'); ws.auto_fragment(false); ws.binary(false); - w.write(ws, buffer(s)); + w.write(ws, net::buffer(s)); multi_buffer b; w.read(ws, b); BEAST_EXPECT(ws.got_text()); @@ -285,7 +283,7 @@ public: std::string const s = "Hello, world!"; ws.auto_fragment(false); ws.binary(false); - w.write(ws, buffer(s)); + w.write(ws, net::buffer(s)); try { multi_buffer b(3); @@ -306,7 +304,7 @@ public: auto const s = std::string(2000, '*') + random_string(); ws.text(true); - w.write(ws, buffer(s)); + w.write(ws, net::buffer(s)); doReadTest(w, ws, close_code::bad_payload); }); @@ -363,7 +361,7 @@ public: { std::string const s = "Hello, world!" "\xc0"; - w.write(ws, buffer(s)); + w.write(ws, net::buffer(s)); doReadTest(w, ws, close_code::bad_payload); }); @@ -437,8 +435,6 @@ public: void doTestReadDeflate(Wrap const& w) { - using net::buffer; - permessage_deflate pmd; pmd.client_enable = true; pmd.server_enable = true; @@ -451,7 +447,7 @@ public: [&](ws_type_t& ws) { std::string const s = std::string(128, '*'); - w.write(ws, buffer(s)); + w.write(ws, net::buffer(s)); ws.read_message_max(32); doFailTest(w, ws, error::message_too_big); }); @@ -490,7 +486,7 @@ public: { auto const& s = random_string(); ws.binary(true); - w.write(ws, buffer(s)); + w.write(ws, net::buffer(s)); multi_buffer b; w.read(ws, b); BEAST_EXPECT(buffers_to_string(b.data()) == s); @@ -504,15 +500,13 @@ public: permessage_deflate const& pmd, Wrap const& w) { - using net::buffer; - // message doTest(pmd, [&](ws_type& ws) { std::string const s = "Hello, world!"; ws.auto_fragment(false); ws.binary(false); - w.write(ws, buffer(s)); + w.write(ws, net::buffer(s)); multi_buffer b; w.read(ws, b); BEAST_EXPECT(ws.got_text()); @@ -533,7 +527,7 @@ public: std::string const s = "Hello, world!"; ws.auto_fragment(false); ws.binary(false); - w.write(ws, buffer(s)); + w.write(ws, net::buffer(s)); multi_buffer b; w.read(ws, b); BEAST_EXPECT(ws.got_text()); @@ -552,7 +546,7 @@ public: { std::string const s = ""; ws.text(true); - w.write(ws, buffer(s)); + w.write(ws, net::buffer(s)); multi_buffer b; w.read(ws, b); BEAST_EXPECT(ws.got_text()); @@ -563,10 +557,10 @@ public: doTest(pmd, [&](ws_type& ws) { std::string const s = "Hello"; - w.write(ws, buffer(s)); + w.write(ws, net::buffer(s)); char buf[3]; auto const bytes_written = - w.read_some(ws, buffer(buf, sizeof(buf))); + w.read_some(ws, net::buffer(buf, sizeof(buf))); BEAST_EXPECT(bytes_written > 0); BEAST_EXPECT( string_view(buf, 3).substr(0, bytes_written) == @@ -577,7 +571,7 @@ public: doTest(pmd, [&](ws_type& ws) { std::string const s = "Hello, world!"; - w.write(ws, buffer(s)); + w.write(ws, net::buffer(s)); multi_buffer b; auto bytes_written = w.read_some(ws, 3, b); @@ -593,7 +587,7 @@ public: { auto const& s = random_string(); ws.binary(true); - w.write(ws, buffer(s)); + w.write(ws, net::buffer(s)); multi_buffer b; w.read(ws, b); BEAST_EXPECT(buffers_to_string(b.data()) == s); @@ -605,7 +599,7 @@ public: std::string const s = "\x03\xea\xf0\x28\x8c\xbc"; ws.auto_fragment(false); ws.text(true); - w.write(ws, buffer(s)); + w.write(ws, net::buffer(s)); doReadTest(w, ws, close_code::bad_payload); }); } @@ -613,8 +607,6 @@ public: void testRead() { - using net::buffer; - doTestRead(SyncClient{}); doTestRead(SyncClient{}); doTestReadDeflate(SyncClient{}); diff --git a/test/beast/websocket/read2.cpp b/test/beast/websocket/read2.cpp index 54647d8f..57b21910 100644 --- a/test/beast/websocket/read2.cpp +++ b/test/beast/websocket/read2.cpp @@ -12,6 +12,7 @@ #include "test.hpp" +#include #include #include #include @@ -26,8 +27,6 @@ public: void testSuspend() { - using net::buffer; -#if 1 // suspend on read block doFailLoop([&](test::fail_count& fc) { @@ -59,12 +58,10 @@ public: ioc.run(); BEAST_EXPECT(count == 2); }); -#endif // suspend on release read block doFailLoop([&](test::fail_count& fc) { -//log << "fc.count()==" << fc.count() << std::endl; echo_server es{log}; net::io_context ioc; stream ws{ioc, fc}; @@ -93,7 +90,6 @@ public: BEAST_EXPECT(count == 2); }); -#if 1 // suspend on write pong doFailLoop([&](test::fail_count& fc) { @@ -118,7 +114,7 @@ public: ++count; }); BEAST_EXPECT(ws.impl_->rd_block.is_locked()); - ws.async_write(buffer(s), + ws.async_write(net::buffer(s), [&](error_code ec, std::size_t n) { if(ec) @@ -217,7 +213,6 @@ public: ioc.run(); BEAST_EXPECT(count == 2); }); -#endif } void diff --git a/test/beast/websocket/test.hpp b/test/beast/websocket/test.hpp index 54dfe2d4..33e474a8 100644 --- a/test/beast/websocket/test.hpp +++ b/test/beast/websocket/test.hpp @@ -10,6 +10,7 @@ #ifndef BEAST_TEST_WEBSOCKET_TEST_HPP #define BEAST_TEST_WEBSOCKET_TEST_HPP +#include #include #include #include @@ -434,7 +435,6 @@ public: DynamicBuffer& buffer, ConstBufferSequence const& buffers) { - using net::buffer_size; buffer.commit(net::buffer_copy( buffer.prepare(buffer_size(buffers)), buffers)); diff --git a/test/beast/websocket/write.cpp b/test/beast/websocket/write.cpp index 9f5886da..ad72db36 100644 --- a/test/beast/websocket/write.cpp +++ b/test/beast/websocket/write.cpp @@ -26,8 +26,6 @@ public: void doTestWrite(Wrap const& w) { - using net::buffer; - permessage_deflate pmd; pmd.client_enable = false; pmd.server_enable = false; @@ -59,7 +57,7 @@ public: ws.auto_fragment(false); ws.binary(false); std::string const s = "Hello, world!"; - w.write(ws, buffer(s)); + w.write(ws, net::buffer(s)); multi_buffer b; w.read(ws, b); BEAST_EXPECT(ws.got_text()); @@ -85,8 +83,8 @@ public: ws.auto_fragment(false); ws.binary(false); std::string const s = "Hello, world!"; - w.write_some(ws, false, buffer(s.data(), 5)); - w.write_some(ws, true, buffer(s.data() + 5, s.size() - 5)); + w.write_some(ws, false, net::buffer(s.data(), 5)); + w.write_some(ws, true, net::buffer(s.data() + 5, s.size() - 5)); multi_buffer b; w.read(ws, b); BEAST_EXPECT(ws.got_text()); @@ -101,8 +99,8 @@ public: std::size_t const chop = 3; BOOST_ASSERT(chop < s.size()); w.write_some(ws, false, - buffer(s.data(), chop)); - w.write_some(ws, true, buffer( + net::buffer(s.data(), chop)); + w.write_some(ws, true, net::buffer( s.data() + chop, s.size() - chop)); flat_buffer b; w.read(ws, b); @@ -115,7 +113,7 @@ public: { ws.auto_fragment(false); std::string const s = "Hello"; - w.write(ws, buffer(s)); + w.write(ws, net::buffer(s)); flat_buffer b; w.read(ws, b); BEAST_EXPECT(buffers_to_string(b.data()) == s); @@ -128,7 +126,7 @@ public: ws.auto_fragment(false); ws.write_buffer_size(16); std::string const s(32, '*'); - w.write(ws, buffer(s)); + w.write(ws, net::buffer(s)); flat_buffer b; w.read(ws, b); BEAST_EXPECT(buffers_to_string(b.data()) == s); @@ -140,7 +138,7 @@ public: { ws.auto_fragment(true); std::string const s(16384, '*'); - w.write(ws, buffer(s)); + w.write(ws, net::buffer(s)); flat_buffer b; w.read(ws, b); BEAST_EXPECT(buffers_to_string(b.data()) == s); @@ -158,7 +156,7 @@ public: w.accept(ws); ws.auto_fragment(false); std::string const s = "Hello"; - w.write(ws, buffer(s)); + w.write(ws, net::buffer(s)); flat_buffer b; w.read(ws, b); BEAST_EXPECT(buffers_to_string(b.data()) == s); @@ -184,7 +182,7 @@ public: w.accept(ws); ws.auto_fragment(true); std::string const s(16384, '*'); - w.write(ws, buffer(s)); + w.write(ws, net::buffer(s)); flat_buffer b; w.read(ws, b); BEAST_EXPECT(buffers_to_string(b.data()) == s); @@ -203,8 +201,6 @@ public: void doTestWriteDeflate(Wrap const& w) { - using net::buffer; - permessage_deflate pmd; pmd.client_enable = true; pmd.server_enable = true; @@ -215,7 +211,7 @@ public: { auto const& s = random_string(); ws.binary(true); - w.write(ws, buffer(s)); + w.write(ws, net::buffer(s)); flat_buffer b; w.read(ws, b); BEAST_EXPECT(buffers_to_string(b.data()) == s); @@ -230,8 +226,8 @@ public: // This call should produce no // output due to compression latency. w.write_some(ws, false, - buffer(s.data(), chop)); - w.write_some(ws, true, buffer( + net::buffer(s.data(), chop)); + w.write_some(ws, true, net::buffer( s.data() + chop, s.size() - chop)); flat_buffer b; w.read(ws, b); @@ -244,7 +240,7 @@ public: { auto const& s = random_string(); ws.binary(true); - w.write(ws, buffer(s)); + w.write(ws, net::buffer(s)); flat_buffer b; w.read(ws, b); BEAST_EXPECT(buffers_to_string(b.data()) == s); @@ -254,8 +250,6 @@ public: void testWrite() { - using net::buffer; - doTestWrite(SyncClient{}); doTestWrite(SyncClient{}); doTestWriteDeflate(SyncClient{}); @@ -271,8 +265,6 @@ public: void testWriteSuspend() { - using net::buffer; - // suspend on ping doFailLoop([&](test::fail_count& fc) { @@ -392,7 +384,7 @@ public: std::size_t count = 0; std::string const s(16384, '*'); ws.auto_fragment(false); - ws.async_write(buffer(s), + ws.async_write(net::buffer(s), [&](error_code ec, std::size_t n) { ++count; @@ -426,7 +418,7 @@ public: std::size_t count = 0; std::string const s(16384, '*'); ws.auto_fragment(true); - ws.async_write(buffer(s), + ws.async_write(net::buffer(s), [&](error_code ec, std::size_t n) { ++count; @@ -459,7 +451,7 @@ public: std::size_t count = 0; std::string const s(16384, '*'); ws.auto_fragment(false); - ws.async_write(buffer(s), + ws.async_write(net::buffer(s), [&](error_code ec, std::size_t n) { ++count; @@ -491,7 +483,7 @@ public: std::size_t count = 0; std::string const s(16384, '*'); ws.auto_fragment(true); - ws.async_write(buffer(s), + ws.async_write(net::buffer(s), [&](error_code ec, std::size_t n) { ++count; @@ -529,7 +521,7 @@ public: std::size_t count = 0; auto const& s = random_string(); ws.binary(true); - ws.async_write(buffer(s), + ws.async_write(net::buffer(s), [&](error_code ec, std::size_t n) { ++count; diff --git a/test/bench/parser/bench_parser.cpp b/test/bench/parser/bench_parser.cpp index ea936152..d95dba4b 100644 --- a/test/bench/parser/bench_parser.cpp +++ b/test/bench/parser/bench_parser.cpp @@ -12,6 +12,7 @@ #include "test/beast/http/message_fuzz.hpp" #include +#include #include #include #include @@ -76,7 +77,6 @@ public: basic_parser& parser, error_code& ec) { - using net::buffer_size; beast::buffers_suffix< ConstBufferSequence> cb{buffers}; std::size_t used = 0; diff --git a/test/bench/wsload/wsload.cpp b/test/bench/wsload/wsload.cpp index 077a52d6..e4ef8236 100644 --- a/test/bench/wsload/wsload.cpp +++ b/test/bench/wsload/wsload.cpp @@ -115,7 +115,7 @@ class connection test_buffer const& tb_; net::strand< net::io_context::executor_type> strand_; - boost::beast::multi_buffer buffer_; + beast::multi_buffer buffer_; std::mt19937_64 rng_; std::size_t count_ = 0; std::size_t bytes_ = 0; @@ -187,11 +187,10 @@ private: void do_write() { - using net::buffer_size; std::geometric_distribution dist{ - double(4) / buffer_size(tb_)}; + double(4) / beast::buffer_size(tb_)}; ws_.async_write_some(true, - boost::beast::buffers_prefix(dist(rng_), tb_), + beast::buffers_prefix(dist(rng_), tb_), alloc_.wrap(std::bind( &connection::on_write, shared_from_this(), @@ -281,7 +280,7 @@ throughput( int main(int argc, char** argv) { - boost::beast::unit_test::dstream dout(std::cerr); + beast::unit_test::dstream dout(std::cerr); try { diff --git a/test/doc/core_1_refresher.cpp b/test/doc/core_1_refresher.cpp index 7ffe3e2c..619f3bdc 100644 --- a/test/doc/core_1_refresher.cpp +++ b/test/doc/core_1_refresher.cpp @@ -95,8 +95,7 @@ std::string string_from_buffers (ConstBufferSequence const& buffers) // optimization: reserve all the space for the string first std::string result; - using net::buffer_size; // buffer_size is a customization point, - result.reserve(buffer_size(buffers)); // called without namespace qualification + result.reserve(beast::buffer_size(buffers)); // beast version of net::buffer_size // iterate over each buffer in the sequence and append it to the string for(auto it = net::buffer_sequence_begin(buffers); // returns an iterator to beginning of the sequence diff --git a/test/doc/exemplars.cpp b/test/doc/exemplars.cpp index 24ef49f9..dd72437d 100644 --- a/test/doc/exemplars.cpp +++ b/test/doc/exemplars.cpp @@ -7,6 +7,7 @@ // Official repository: https://github.com/boostorg/beast // +#include #include #include #include @@ -164,7 +165,6 @@ struct BodyReader // The specification requires this to indicate "no error" ec = {}; - using net::buffer_size; return buffer_size(buffers); } diff --git a/test/doc/http_snippets.cpp b/test/doc/http_snippets.cpp index eb1911ce..1a4f83c5 100644 --- a/test/doc/http_snippets.cpp +++ b/test/doc/http_snippets.cpp @@ -272,7 +272,6 @@ void fxx() { auto const cb3 = get_next_chunk_body(); // Manually emit a chunk by first writing the chunk-size header with the correct size - using net::buffer_size; net::write(sock, chunk_header{ buffer_size(cb1) + buffer_size(cb2) + @@ -368,7 +367,6 @@ print_cxx14(message const& m) { ec = {}; std::cout << buffers(buffer); - using net::buffer_size; sr.consume(buffer_size(buffer)); }); } @@ -396,7 +394,6 @@ struct lambda { ec = {}; std::cout << buffers(buffer); - using net::buffer_size; sr.consume(buffer_size(buffer)); } }; @@ -438,7 +435,6 @@ split_print_cxx14(message const& m) { ec = {}; std::cout << buffers(buffer); - using net::buffer_size; sr.consume(buffer_size(buffer)); }); } @@ -453,7 +449,6 @@ split_print_cxx14(message const& m) { ec = {}; std::cout << buffers(buffer); - using net::buffer_size; sr.consume(buffer_size(buffer)); }); } diff --git a/test/doc/websocket_snippets.cpp b/test/doc/websocket_snippets.cpp index fa2e3214..6e108926 100644 --- a/test/doc/websocket_snippets.cpp +++ b/test/doc/websocket_snippets.cpp @@ -202,7 +202,6 @@ boost::ignore_unused(ec); // This will cause the message to be broken up into multiple frames. for(;;) { - using net::buffer_size; if(buffer_size(cb) > 512) { // There are more than 512 bytes left to send, just