diff --git a/CHANGELOG.md b/CHANGELOG.md index 15e3562d..ee89a19e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ Version 198: * saved_handler maintains a work_guard (websocket) * Add buffer_traits.hpp, buffers_type * Tidy up experimental files +* Tidy up core files API Changes: diff --git a/doc/source.dox b/doc/source.dox index 705ab158..a9c5737f 100644 --- a/doc/source.dox +++ b/doc/source.dox @@ -289,9 +289,9 @@ PREDEFINED = \ BOOST_BEAST_DOXYGEN \ BOOST_BEAST_USE_POSIX_FILE=1 \ BOOST_BEAST_USE_WIN32_FILE=1 \ - BOOST_ASIO_INITFN_RESULT_TYPE(t,a)=void_or_deduced \ - GENERATING_DOCUMENTATION - + BOOST_ASIO_INITFN_RESULT_TYPE(t,a)=__deduced__ \ + GENERATING_DOCUMENTATION \ + BOOST_BEAST_DECL EXPAND_AS_DEFINED = SKIP_FUNCTION_MACROS = YES diff --git a/doc/xsl/class_detail.xsl b/doc/xsl/class_detail.xsl index 5ef923f5..dab37942 100644 --- a/doc/xsl/class_detail.xsl +++ b/doc/xsl/class_detail.xsl @@ -9,7 +9,7 @@ class __AsyncWriteStream__ - class ``[link beast.concepts.Body [*Body]]`` + class __Body__ class ``[link beast.concepts.BufferSequence [*BufferSequence]]`` @@ -76,24 +76,3 @@ class __WriteHandler__ - - - - - class __Protocol__ - - - class __Executor__ - - - class __EndpointSequence__ - - - class __RangeConnectHandler__ - - - class __ConnectCondition__ - - - class __IteratorConnectHandler__ - diff --git a/include/boost/beast/core/buffered_read_stream.hpp b/include/boost/beast/core/buffered_read_stream.hpp index db873854..3ad17f7e 100644 --- a/include/boost/beast/core/buffered_read_stream.hpp +++ b/include/boost/beast/core/buffered_read_stream.hpp @@ -31,7 +31,7 @@ namespace beast { is part of the object. The use-case for this class is different than that of the - `net::buffered_readstream`. It is designed to facilitate + `net::buffered_read_stream`. It is designed to facilitate the use of `net::read_until`, and to allow buffers acquired during detection of handshakes to be made transparently available to callers. A hypothetical implementation of the @@ -51,9 +51,9 @@ namespace beast { // Process the next HTTP header on the stream, // leaving excess bytes behind for the next call. // - template + template void process_http_message( - buffered_read_stream& stream) + buffered_read_stream& stream) { // Read up to and including the end of the HTTP // header, leaving the sequence in the stream's @@ -137,28 +137,28 @@ public: /// Get a reference to the next layer. next_layer_type& - next_layer() + next_layer() noexcept { return next_layer_; } /// Get a const reference to the next layer. next_layer_type const& - next_layer() const + next_layer() const noexcept { return next_layer_; } /// Get a reference to the lowest layer. lowest_layer_type& - lowest_layer() + lowest_layer() noexcept { return next_layer_.lowest_layer(); } /// Get a const reference to the lowest layer. lowest_layer_type const& - lowest_layer() const + lowest_layer() const noexcept { return next_layer_.lowest_layer(); } @@ -196,14 +196,14 @@ public: the caller defined maximum. */ DynamicBuffer& - buffer() + buffer() noexcept { return buffer_; } /// Access the internal buffer DynamicBuffer const& - buffer() const + buffer() const noexcept { return buffer_; } @@ -224,7 +224,7 @@ public: than the amount of data in the buffer, no bytes are discarded. */ void - capacity(std::size_t size) + capacity(std::size_t size) noexcept { capacity_ = size; } @@ -367,6 +367,6 @@ public: } // beast } // boost -#include +#include #endif diff --git a/include/boost/beast/core/buffers_adapter.hpp b/include/boost/beast/core/buffers_adapter.hpp index 660d0db8..e545ca9a 100644 --- a/include/boost/beast/core/buffers_adapter.hpp +++ b/include/boost/beast/core/buffers_adapter.hpp @@ -19,11 +19,11 @@ namespace boost { namespace beast { -/** Adapts a @b MutableBufferSequence into a @b DynamicBuffer. +/** Adapts a MutableBufferSequence into a DynamicBuffer. - This class wraps a @b MutableBufferSequence to meet the requirements - of @b DynamicBuffer. Upon construction the input and output sequences are - empty. A copy of the mutable buffer sequence object is stored; however, + This class wraps a MutableBufferSequence to meet the requirements + of DynamicBuffer. Upon construction the input and output sequences + are empty. A copy of the mutable buffer sequence object is stored; however, ownership of the underlying memory is not transferred. The caller is responsible for making sure that referenced memory remains valid for the duration of any operations. @@ -36,7 +36,8 @@ namespace beast { template class buffers_adapter { - static_assert(net::is_mutable_buffer_sequence::value, + static_assert(net::is_mutable_buffer_sequence< + MutableBufferSequence>::value, "MutableBufferSequence requirements not met"); using iter_type = typename @@ -75,20 +76,6 @@ public: /// The type of the underlying mutable buffer sequence using value_type = MutableBufferSequence; -#if BOOST_BEAST_DOXYGEN - /// The type used to represent the input sequence as a list of buffers. - using const_buffers_type = __implementation_defined__; - - /// The type used to represent the output sequence as a list of buffers. - using mutable_buffers_type = __implementation_defined__; - -#else - class const_buffers_type; - - class mutable_buffers_type; - -#endif - /// Move constructor. buffers_adapter(buffers_adapter&& other); @@ -121,27 +108,6 @@ public: explicit buffers_adapter(boost::in_place_init_t, Args&&... args); - /// Returns the largest size output sequence possible. - std::size_t - max_size() const - { - return max_size_; - } - - /// Get the size of the input sequence. - std::size_t - size() const - { - return in_size_; - } - - /// Returns the maximum sum of the sizes of the input sequence and output sequence the buffer can hold without requiring reallocation. - std::size_t - capacity() const - { - return max_size_; - } - /// Returns the original mutable buffer sequence value_type const& value() const @@ -149,40 +115,112 @@ public: return bs_; } - /** Get a list of buffers that represents the output sequence, with the given size. + //-------------------------------------------------------------------------- - @throws std::length_error if the size would exceed the limit - imposed by the underlying mutable buffer sequence. +#if BOOST_BEAST_DOXYGEN + /// The ConstBufferSequence used to represent the readable bytes. + using const_buffers_type = __implementation_defined__; - @note Buffers representing the input sequence acquired prior to - this call remain valid. + /// The MutableBufferSequence used to represent the writable bytes. + using mutable_buffers_type = __implementation_defined__; + +#else + class const_buffers_type; + class mutable_buffers_type; +#endif + + /// Returns the number of readable bytes. + std::size_t + size() const noexcept + { + return in_size_; + } + + /// Return the maximum number of bytes, both readable and writable, that can ever be held. + std::size_t + max_size() const noexcept + { + return max_size_; + } + + /// Return the maximum number of bytes, both readable and writable, that can be held without requiring an allocation. + std::size_t + capacity() const noexcept + { + return max_size_; + } + + /// Returns a constant buffer sequence representing the readable bytes + const_buffers_type + data() const noexcept; + + /** Returns a mutable buffer sequence representing writable bytes. + + Returns a mutable buffer sequence representing the writable + bytes containing exactly `n` bytes of storage. This function + does not allocate memory. Instead, the storage comes from + the underlying mutable buffer sequence. + + All buffer sequences previously obtained using @ref prepare are + invalidated. Buffer sequences previously obtained using @ref data + remain valid. + + @param n The desired number of bytes in the returned buffer + sequence. + + @throws std::length_error if `size() + n` exceeds `max_size()`. + + @par Exception Safety + + Strong guarantee. */ mutable_buffers_type prepare(std::size_t n); - /** Move bytes from the output sequence to the input sequence. + /** Append writable bytes to the readable bytes. - @note Buffers representing the input sequence acquired prior to - this call remain valid. + Appends n bytes from the start of the writable bytes to the + end of the readable bytes. The remainder of the writable bytes + are discarded. If n is greater than the number of writable + bytes, all writable bytes are appended to the readable bytes. + + All buffer sequences previously obtained using @ref prepare are + invalidated. Buffer sequences previously obtained using @ref data + remain valid. + + @param n The number of bytes to append. If this number + is greater than the number of writable bytes, all + writable bytes are appended. + + @par Exception Safety + + No-throw guarantee. */ void - commit(std::size_t n); + commit(std::size_t n) noexcept; - /** Get a list of buffers that represents the input sequence. + /** Remove bytes from beginning of the readable bytes. - @note These buffers remain valid across subsequent calls to `prepare`. + Removes n bytes from the beginning of the readable bytes. + + All buffers sequences previously obtained using + @ref data or @ref prepare are invalidated. + + @param n The number of bytes to remove. If this number + is greater than the number of readable bytes, all + readable bytes are removed. + + @par Exception Safety + + No-throw guarantee. */ - const_buffers_type - data() const; - - /// Remove bytes from the input sequence. void - consume(std::size_t n); + consume(std::size_t n) noexcept; }; } // beast } // boost -#include +#include #endif diff --git a/include/boost/beast/core/buffers_cat.hpp b/include/boost/beast/core/buffers_cat.hpp index 2befd0b3..b85fedae 100644 --- a/include/boost/beast/core/buffers_cat.hpp +++ b/include/boost/beast/core/buffers_cat.hpp @@ -11,7 +11,7 @@ #define BOOST_BEAST_BUFFERS_CAT_HPP #include -#include +#include #include namespace boost { @@ -24,12 +24,12 @@ namespace beast { template class buffers_cat_view { - detail::lean_tuple bn_; + detail::tuple bn_; public: /** The type of buffer returned when dereferencing an iterator. - If every buffer sequence in the view is a @b MutableBufferSequence, + If every buffer sequence in the view is a MutableBufferSequence, then `value_type` will be `net::mutable_buffer`. Otherwise, `value_type` will be `net::const_buffer`. */ @@ -43,34 +43,33 @@ public: /// The type of iterator used by the concatenated sequence class const_iterator; - /// Constructor + /// Copy Constructor + buffers_cat_view(buffers_cat_view const&) = default; + + /// Move Constructor buffers_cat_view(buffers_cat_view&&) = default; - /// Assignment - buffers_cat_view& operator=(buffers_cat_view&&) = default; - - /// Assignment + /// Copy Assignment buffers_cat_view& operator=(buffers_cat_view const&) = default; + /// Move Assignment + buffers_cat_view& operator=(buffers_cat_view&&) = default; + /** Constructor @param buffers The list of buffer sequences to concatenate. - Copies of the arguments will be made; however, the ownership - of memory is not transferred. + Copies of the arguments will be maintained for the lifetime + of the concatenated sequence; however, the ownership of memory + is not transferred. */ explicit buffers_cat_view(Buffers const&... buffers); - //----- - - /// Required for @b BufferSequence - buffers_cat_view(buffers_cat_view const&) = default; - - /// Required for @b BufferSequence + /// Returns an iterator to the first buffer in the sequence const_iterator begin() const; - /// Required for @b BufferSequence + /// Returns an iterator to one past the last buffer in the sequence const_iterator end() const; }; @@ -88,9 +87,9 @@ public: @return A new buffer sequence that represents the concatenation of the input buffer sequences. This buffer sequence will be a - @b MutableBufferSequence if each of the passed buffer sequences is - also a @b MutableBufferSequence; otherwise the returned buffer - sequence will be a @b ConstBufferSequence. + MutableBufferSequence if each of the passed buffer sequences is + also a MutableBufferSequence; otherwise the returned buffer + sequence will be a ConstBufferSequence. @see @ref buffers_cat_view */ @@ -100,7 +99,6 @@ buffers_cat_view buffers_cat(BufferSequence const&... buffers) #else template -inline buffers_cat_view buffers_cat(B1 const& b1, B2 const& b2, Bn const&... bn) #endif @@ -114,6 +112,6 @@ buffers_cat(B1 const& b1, B2 const& b2, Bn const&... bn) } // beast } // boost -#include +#include #endif diff --git a/include/boost/beast/core/buffers_prefix.hpp b/include/boost/beast/core/buffers_prefix.hpp index e85596fa..003c0e79 100644 --- a/include/boost/beast/core/buffers_prefix.hpp +++ b/include/boost/beast/core/buffers_prefix.hpp @@ -13,7 +13,8 @@ #include #include #include -#include +#include // for in_place_init_t +#include #include #include @@ -73,16 +74,16 @@ public: #endif - /// Move constructor. + /// Move Constructor buffers_prefix_view(buffers_prefix_view&&); - /// Copy constructor. + /// Copy Constructor buffers_prefix_view(buffers_prefix_view const&); - /// Move assignment. + /// Move Assignment buffers_prefix_view& operator=(buffers_prefix_view&&); - /// Copy assignment. + /// Copy Assignment buffers_prefix_view& operator=(buffers_prefix_view const&); /** Construct a buffer sequence prefix. @@ -94,7 +95,8 @@ public: @param buffers The buffer sequence to adapt. A copy of the sequence will be made, but ownership of the underlying - memory is not transferred. + memory is not transferred. The copy is maintained for + the lifetime of the view. */ buffers_prefix_view( std::size_t size, @@ -115,96 +117,117 @@ public: boost::in_place_init_t, Args&&... args); - /// Get a bidirectional iterator to the first element. + /// Returns an iterator to the first buffer in the sequence const_iterator begin() const; - /// Get a bidirectional iterator to one past the last element. + /// Returns an iterator to one past the last buffer in the sequence const_iterator end() const; }; +//------------------------------------------------------------------------------ + /** Returns a prefix of a constant buffer. - The returned buffer points to the same memory as the - passed buffer, but with a size that is equal to or less - than the size of the original buffer. + The returned buffer points to the same memory as the passed + buffer, but with a size that is equal to or smaller. - @param size The size of the returned buffer. + @param size The maximum size of the returned buffer in bytes. If + this is greater than or equal to the size of the passed buffer, + the result will have the same size as the original buffer. - @param buffer The buffer to shorten. The underlying - memory is not modified. + @param buffer The buffer to return a prefix for. The + underlying memory is not modified, and ownership of the + memory is not transferred. - @return A new buffer that points to the first `size` - bytes of the original buffer. + @return A constant buffer that represents the prefix of + the original buffer. + + @par Exception Safety + + No-throw guarantee. */ inline net::const_buffer buffers_prefix(std::size_t size, - net::const_buffer buffer) + net::const_buffer buffer) noexcept { - return {buffer.data(), - (std::min)(size, buffer.size())}; + return {buffer.data(), std::min< + std::size_t>(size, buffer.size())}; } /** Returns a prefix of a mutable buffer. - The returned buffer points to the same memory as the - passed buffer, but with a size that is equal to or less - than the size of the original buffer. + The returned buffer points to the same memory as the passed + buffer, but with a size that is equal to or smaller. - @param size The size of the returned buffer. + @param size The maximum size of the returned buffer in bytes. If + this is greater than or equal to the size of the passed buffer, + the result will have the same size as the original buffer. - @param buffer The buffer to shorten. The underlying - memory is not modified. + @param buffer The buffer to return a prefix for. The + underlying memory is not modified, and ownership of the + memory is not transferred. - @return A new buffer that points to the first `size` bytes - of the original buffer. + @return A mutable buffer that represents the prefix of + the original buffer. */ inline net::mutable_buffer buffers_prefix(std::size_t size, - net::mutable_buffer buffer) + net::mutable_buffer buffer) noexcept { - return {buffer.data(), - (std::min)(size, buffer.size())}; + return {buffer.data(), std::min< + std::size_t>(size, buffer.size())}; } -/** Returns a prefix of a buffer sequence. +/** Returns a prefix of a constant or mutable buffer sequence. - This function returns a new buffer sequence which when iterated, - presents a shorter subset of the original list of buffers starting - with the first byte of the original sequence. + The returned buffer sequence points to the same memory as the + passed buffer sequence, but with a size that is equal to or + smaller. No memory allocations are performed; the resulting + sequence is calculated as a lazy range. - @param size The maximum number of bytes in the wrapped - sequence. If this is larger than the size of passed, - buffers, the resulting sequence will represent the - entire input sequence. + @param size The maximum size of the returned buffer sequence + in bytes. If this is greater than or equal to the size of + the passed buffer sequence, the result will have the same + size as the original buffer sequence. - @param buffers An instance of @b ConstBufferSequence or - @b MutableBufferSequence to adapt. A copy of the sequence - will be made, but ownership of the underlying memory is - not transferred. + @param buffers An object whose type meets the requirements + of ConstBufferSequence. The returned value will + maintain a copy of the passed buffers for its lifetime; + however, ownership of the underlying memory is not + transferred. + + @return A constant buffer sequence that represents the prefix + of the original buffer sequence. If the original buffer sequence + also meets the requirements of MutableBufferSequence, + then the returned value will also be a mutable buffer sequence. + + @note This function does not participate in overload resolution + if `buffers` is convertible to either `net::const_buffer` or + `net::mutable_buffer`. */ -template +template #if BOOST_BEAST_DOXYGEN -buffers_prefix_view +buffers_prefix_view #else inline typename std::enable_if< - ! std::is_same::value && - ! std::is_same::value, - buffers_prefix_view>::type + buffers_prefix_view>::type #endif -buffers_prefix(std::size_t size, BufferSequence const& buffers) +buffers_prefix(std::size_t size, ConstBufferSequence const& buffers) { static_assert( - net::is_const_buffer_sequence::value || - net::is_mutable_buffer_sequence::value, - "BufferSequence requirements not met"); - return buffers_prefix_view(size, buffers); + net::is_const_buffer_sequence::value || + net::is_mutable_buffer_sequence::value, + "ConstBufferSequence requirements not met"); + return buffers_prefix_view(size, buffers); } /** Returns the first buffer in a buffer sequence @@ -234,6 +257,6 @@ buffers_front(BufferSequence const& buffers) } // beast } // boost -#include +#include #endif diff --git a/include/boost/beast/core/buffers_range.hpp b/include/boost/beast/core/buffers_range.hpp index 3eb24492..1e6bcd69 100644 --- a/include/boost/beast/core/buffers_range.hpp +++ b/include/boost/beast/core/buffers_range.hpp @@ -18,7 +18,7 @@ namespace boost { namespace beast { -/** Return a range representing a const or mutable buffer sequence. +/** Returns an iterable range representing a buffer sequence. This function returns an iterable range representing the passed buffer sequence. The values obtained when iterating @@ -51,7 +51,7 @@ namespace beast { the lifetime of the returned range. @return An object of unspecified type, meeting the requirements of - @em ConstBufferSequence, or @em MutableBufferSequence if `buffers` + ConstBufferSequence, and also @em MutableBufferSequence if `buffers` is a mutable buffer sequence. */ /** @{ */ diff --git a/include/boost/beast/core/buffers_suffix.hpp b/include/boost/beast/core/buffers_suffix.hpp index 101b8d2a..61ea1f77 100644 --- a/include/boost/beast/core/buffers_suffix.hpp +++ b/include/boost/beast/core/buffers_suffix.hpp @@ -21,12 +21,12 @@ namespace boost { namespace beast { -/** Adapter to trim the front of a `BufferSequence`. +/** Adaptor to progressively trim the front of a BufferSequence. - This adapter wraps a buffer sequence to create a new sequence + This adaptor wraps a buffer sequence to create a new sequence which may be incrementally consumed. Bytes consumed are removed from the front of the buffer. The underlying memory is not changed, - instead the adapter efficiently iterates through a subset of + instead the adaptor efficiently iterates through a subset of the buffers wrapped. The wrapped buffer is not modified, a copy is made instead. @@ -104,10 +104,7 @@ public: /// Constructor buffers_suffix(); - /// Constructor - buffers_suffix(buffers_suffix&&); - - /// Constructor + /// Copy Constructor buffers_suffix(buffers_suffix const&); /** Constructor @@ -128,9 +125,6 @@ public: template buffers_suffix(boost::in_place_init_t, Args&&... args); - /// Assignment - buffers_suffix& operator=(buffers_suffix&&); - /// Assignment buffers_suffix& operator=(buffers_suffix const&); @@ -155,6 +149,6 @@ public: } // beast } // boost -#include +#include #endif diff --git a/include/boost/beast/core/buffers_to_string.hpp b/include/boost/beast/core/buffers_to_string.hpp index 726342c2..8aed006c 100644 --- a/include/boost/beast/core/buffers_to_string.hpp +++ b/include/boost/beast/core/buffers_to_string.hpp @@ -48,8 +48,9 @@ buffers_to_string(ConstBufferSequence const& buffers) net::is_const_buffer_sequence::value, "ConstBufferSequence requirements not met"); std::string result; - result.reserve(net::buffer_size(buffers)); - for(auto const buffer : buffers_range(std::ref(buffers))) + using net::buffer_size; + result.reserve(buffer_size(buffers)); + for(auto const buffer : beast::buffers_range(std::ref(buffers))) result.append(static_cast( buffer.data()), buffer.size()); return result; diff --git a/include/boost/beast/core/detail/base64.hpp b/include/boost/beast/core/detail/base64.hpp index 6cb3f67a..735da0f3 100644 --- a/include/boost/beast/core/detail/base64.hpp +++ b/include/boost/beast/core/detail/base64.hpp @@ -34,12 +34,12 @@ 3. This notice may not be removed or altered from any source distribution. Rene Nyffenegger rene.nyffenegger@adp-gmbh.ch - */ #ifndef BOOST_BEAST_DETAIL_BASE64_HPP #define BOOST_BEAST_DETAIL_BASE64_HPP +#include #include #include #include @@ -55,7 +55,10 @@ char const* get_alphabet() { static char constexpr tab[] = { - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" + "ABCDEFGHIJKLMNOP" + "QRSTUVWXYZabcdef" + "ghijklmnopqrstuv" + "wxyz0123456789+/" }; return &tab[0]; } @@ -115,7 +118,7 @@ decoded_size(std::size_t n) @return The number of characters written to `out`. This will exclude any null termination. */ -template +inline std::size_t encode(void* dest, void const* src, std::size_t len) { @@ -166,7 +169,7 @@ encode(void* dest, void const* src, std::size_t len) the number of characters read from the input string, expressed as a pair. */ -template +inline std::pair decode(void* dest, char const* src, std::size_t len) { @@ -213,9 +216,10 @@ decode(void* dest, char const* src, std::size_t len) } // base64 -template +inline std::string -base64_encode (std::uint8_t const* data, +base64_encode( + std::uint8_t const* data, std::size_t len) { std::string dest; @@ -226,7 +230,7 @@ base64_encode (std::uint8_t const* data, inline std::string -base64_encode(std::string const& s) +base64_encode(string_view s) { return base64_encode (reinterpret_cast < std::uint8_t const*> (s.data()), s.size()); @@ -234,7 +238,7 @@ base64_encode(std::string const& s) template std::string -base64_decode(std::string const& data) +base64_decode(string_view data) { std::string dest; dest.resize(base64::decoded_size(data.size())); diff --git a/include/boost/beast/core/detail/bind_handler.hpp b/include/boost/beast/core/detail/bind_handler.hpp index 42806487..411f8550 100644 --- a/include/boost/beast/core/detail/bind_handler.hpp +++ b/include/boost/beast/core/detail/bind_handler.hpp @@ -11,18 +11,18 @@ #define BOOST_BEAST_DETAIL_BIND_HANDLER_HPP #include -#include +#include #include #include +#include #include #include #include #include #include #include -#include - #include +#include namespace boost { namespace beast { @@ -31,7 +31,7 @@ namespace detail { template class bind_wrapper { - using args_type = detail::lean_tuple< + using args_type = detail::tuple< typename std::decay::type...>; Handler h_; @@ -94,7 +94,7 @@ class bind_wrapper invoke( Handler& h, ArgsTuple& args, - lean_tuple<>&&, + tuple<>&&, mp11::index_sequence) { boost::ignore_unused(args); @@ -122,9 +122,6 @@ class bind_wrapper public: using result_type = void; - using allocator_type = - net::associated_allocator_t; - bind_wrapper(bind_wrapper&&) = default; bind_wrapper(bind_wrapper const&) = default; @@ -137,47 +134,76 @@ public: { } - allocator_type - get_allocator() const noexcept - { - return (net::get_associated_allocator)(h_); - } - - friend - bool - asio_handler_is_continuation(bind_wrapper* w) - { - using net::asio_handler_is_continuation; - return asio_handler_is_continuation(std::addressof(w->h_)); - } - - template - friend - void asio_handler_invoke(Function&& f, bind_wrapper* w) - { - using net::asio_handler_invoke; - asio_handler_invoke(f, std::addressof(w->h_)); - } - template void operator()(Values&&... values) { invoke(h_, args_, - lean_tuple( + tuple( std::forward(values)...), mp11::index_sequence_for()); } + // VFALCO I don't think this should be needed, + // please let me know if something breaks. + /* template void operator()(Values&&... values) const { invoke(h_, args_, - lean_tuple( + tuple( std::forward(values)...), mp11::index_sequence_for()); } + */ + + // + + using allocator_type = + net::associated_allocator_t; + + allocator_type + get_allocator() const noexcept + { + return net::get_associated_allocator(h_); + } + + template + friend + void asio_handler_invoke( + Function&& f, bind_wrapper* w) + { + using net::asio_handler_invoke; + asio_handler_invoke(f, std::addressof(w->h_)); + } + + friend + void* asio_handler_allocate( + std::size_t size, bind_wrapper* op) + { + using net::asio_handler_allocate; + return asio_handler_allocate( + size, std::addressof(op->h_)); + } + + friend + void asio_handler_deallocate( + void* p, std::size_t size, bind_wrapper* op) + { + using net::asio_handler_deallocate; + asio_handler_deallocate( + p, size, std::addressof(op->h_)); + } + + friend + bool asio_handler_is_continuation( + bind_wrapper* op) + { + using net::asio_handler_is_continuation; + return asio_handler_is_continuation( + std::addressof(op->h_)); + } }; //------------------------------------------------------------------------------ @@ -199,9 +225,6 @@ class bind_front_wrapper public: using result_type = void; - using allocator_type = - net::associated_allocator_t; - bind_front_wrapper(bind_front_wrapper&&) = default; bind_front_wrapper(bind_front_wrapper const&) = default; @@ -212,32 +235,57 @@ public: { } + template + void operator()(Ts&&... ts) + { + h_(std::forward(ts)...); + } + + // + + using allocator_type = + net::associated_allocator_t; + allocator_type get_allocator() const noexcept { return net::get_associated_allocator(h_); } - friend - bool - asio_handler_is_continuation(bind_front_wrapper* w) - { - using net::asio_handler_is_continuation; - return asio_handler_is_continuation(std::addressof(w->h_)); - } - template friend - void asio_handler_invoke(Function&& f, bind_front_wrapper* w) + void asio_handler_invoke( + Function&& f, bind_front_wrapper* w) { using net::asio_handler_invoke; asio_handler_invoke(f, std::addressof(w->h_)); } - template - void operator()(Ts&&... ts) + friend + void* asio_handler_allocate( + std::size_t size, bind_front_wrapper* op) { - h_(std::forward(ts)...); + using net::asio_handler_allocate; + return asio_handler_allocate( + size, std::addressof(op->h_)); + } + + friend + void asio_handler_deallocate( + void* p, std::size_t size, bind_front_wrapper* op) + { + using net::asio_handler_deallocate; + asio_handler_deallocate( + p, size, std::addressof(op->h_)); + } + + friend + bool asio_handler_is_continuation( + bind_front_wrapper* op) + { + using net::asio_handler_is_continuation; + return asio_handler_is_continuation( + std::addressof(op->h_)); } }; @@ -256,9 +304,6 @@ class bind_front_wrapper public: using result_type = void; - using allocator_type = - net::associated_allocator_t; - bind_front_wrapper(bind_front_wrapper&&) = default; bind_front_wrapper(bind_front_wrapper const&) = default; @@ -270,33 +315,58 @@ public: { } + template + void operator()(Ts&&... ts) + { + h_( std::forward(arg_), + std::forward(ts)...); + } + + // + + using allocator_type = + net::associated_allocator_t; + allocator_type get_allocator() const noexcept { return net::get_associated_allocator(h_); } - friend - bool - asio_handler_is_continuation(bind_front_wrapper* w) - { - using net::asio_handler_is_continuation; - return asio_handler_is_continuation(std::addressof(w->h_)); - } - template friend - void asio_handler_invoke(Function&& f, bind_front_wrapper* w) + void asio_handler_invoke( + Function&& f, bind_front_wrapper* w) { using net::asio_handler_invoke; asio_handler_invoke(f, std::addressof(w->h_)); } - template - void operator()(Ts&&... ts) + friend + void* asio_handler_allocate( + std::size_t size, bind_front_wrapper* op) { - h_( std::forward(arg_), - std::forward(ts)...); + using net::asio_handler_allocate; + return asio_handler_allocate( + size, std::addressof(op->h_)); + } + + friend + void asio_handler_deallocate( + void* p, std::size_t size, bind_front_wrapper* op) + { + using net::asio_handler_deallocate; + asio_handler_deallocate( + p, size, std::addressof(op->h_)); + } + + friend + bool asio_handler_is_continuation( + bind_front_wrapper* op) + { + using net::asio_handler_is_continuation; + return asio_handler_is_continuation( + std::addressof(op->h_)); } }; @@ -316,9 +386,6 @@ class bind_front_wrapper public: using result_type = void; - using allocator_type = - net::associated_allocator_t; - bind_front_wrapper(bind_front_wrapper&&) = default; bind_front_wrapper(bind_front_wrapper const&) = default; @@ -331,28 +398,6 @@ public: { } - allocator_type - get_allocator() const noexcept - { - return net::get_associated_allocator(h_); - } - - friend - bool - asio_handler_is_continuation(bind_front_wrapper* w) - { - using net::asio_handler_is_continuation; - return asio_handler_is_continuation(std::addressof(w->h_)); - } - - template - friend - void asio_handler_invoke(Function&& f, bind_front_wrapper* w) - { - using net::asio_handler_invoke; - asio_handler_invoke(f, std::addressof(w->h_)); - } - template void operator()(Ts&&... ts) { @@ -360,6 +405,53 @@ public: std::forward(arg2_), std::forward(ts)...); } + + // + + using allocator_type = + net::associated_allocator_t; + + allocator_type + get_allocator() const noexcept + { + return net::get_associated_allocator(h_); + } + + template + friend + void asio_handler_invoke( + Function&& f, bind_front_wrapper* w) + { + using net::asio_handler_invoke; + asio_handler_invoke(f, std::addressof(w->h_)); + } + + friend + void* asio_handler_allocate( + std::size_t size, bind_front_wrapper* op) + { + using net::asio_handler_allocate; + return asio_handler_allocate( + size, std::addressof(op->h_)); + } + + friend + void asio_handler_deallocate( + void* p, std::size_t size, bind_front_wrapper* op) + { + using net::asio_handler_deallocate; + asio_handler_deallocate( + p, size, std::addressof(op->h_)); + } + + friend + bool asio_handler_is_continuation( + bind_front_wrapper* op) + { + using net::asio_handler_is_continuation; + return asio_handler_is_continuation( + std::addressof(op->h_)); + } }; // 3+ arg specialization @@ -367,7 +459,7 @@ template class bind_front_wrapper { - using args_type = lean_tuple< + using args_type = tuple< typename std::decay::type, typename std::decay::type, typename std::decay::type, @@ -394,9 +486,6 @@ class bind_front_wrapper public: using result_type = void; - using allocator_type = - net::associated_allocator_t; - bind_front_wrapper(bind_front_wrapper&&) = default; bind_front_wrapper(bind_front_wrapper const&) = default; @@ -413,28 +502,6 @@ public: { } - allocator_type - get_allocator() const noexcept - { - return net::get_associated_allocator(h_); - } - - friend - bool - asio_handler_is_continuation(bind_front_wrapper* w) - { - using net::asio_handler_is_continuation; - return asio_handler_is_continuation(std::addressof(w->h_)); - } - - template - friend - void asio_handler_invoke(Function&& f, bind_front_wrapper* w) - { - using net::asio_handler_invoke; - asio_handler_invoke(f, std::addressof(w->h_)); - } - template void operator()(Ts&&... ts) { @@ -443,6 +510,53 @@ public: Arg1, Arg2, Arg3, Args...>{}, std::forward(ts)...); } + + // + + using allocator_type = + net::associated_allocator_t; + + allocator_type + get_allocator() const noexcept + { + return net::get_associated_allocator(h_); + } + + template + friend + void asio_handler_invoke( + Function&& f, bind_front_wrapper* w) + { + using net::asio_handler_invoke; + asio_handler_invoke(f, std::addressof(w->h_)); + } + + friend + void* asio_handler_allocate( + std::size_t size, bind_front_wrapper* op) + { + using net::asio_handler_allocate; + return asio_handler_allocate( + size, std::addressof(op->h_)); + } + + friend + void asio_handler_deallocate( + void* p, std::size_t size, bind_front_wrapper* op) + { + using net::asio_handler_deallocate; + asio_handler_deallocate( + p, size, std::addressof(op->h_)); + } + + friend + bool asio_handler_is_continuation( + bind_front_wrapper* op) + { + using net::asio_handler_is_continuation; + return asio_handler_is_continuation( + std::addressof(op->h_)); + } }; //------------------------------------------------------------------------------ @@ -460,9 +574,6 @@ class bind_front_wrapper< public: using result_type = void; - using allocator_type = - net::associated_allocator_t; - bind_front_wrapper(bind_front_wrapper&&) = default; bind_front_wrapper(bind_front_wrapper const&) = default; @@ -475,39 +586,66 @@ public: { } + void operator()() + { + h_(ec_, n_); + } + + // + + using allocator_type = + net::associated_allocator_t; + allocator_type get_allocator() const noexcept { return net::get_associated_allocator(h_); } - friend - bool - asio_handler_is_continuation(bind_front_wrapper* w) - { - using net::asio_handler_is_continuation; - return asio_handler_is_continuation(std::addressof(w->h_)); - } - template friend - void asio_handler_invoke(Function&& f, bind_front_wrapper* w) + void asio_handler_invoke( + Function&& f, bind_front_wrapper* w) { using net::asio_handler_invoke; asio_handler_invoke(f, std::addressof(w->h_)); } - void operator()() + friend + void* asio_handler_allocate( + std::size_t size, bind_front_wrapper* op) { - h_(ec_, n_); + using net::asio_handler_allocate; + return asio_handler_allocate( + size, std::addressof(op->h_)); + } + + friend + void asio_handler_deallocate( + void* p, std::size_t size, bind_front_wrapper* op) + { + using net::asio_handler_deallocate; + asio_handler_deallocate( + p, size, std::addressof(op->h_)); + } + + friend + bool asio_handler_is_continuation( + bind_front_wrapper* op) + { + using net::asio_handler_is_continuation; + return asio_handler_is_continuation( + std::addressof(op->h_)); } }; } // detail } // beast +} // boost //------------------------------------------------------------------------------ +namespace boost { namespace asio { template @@ -545,9 +683,10 @@ struct associated_executor< }; } // asio - } // boost +//------------------------------------------------------------------------------ + namespace std { template @@ -562,4 +701,6 @@ bind(boost::beast::detail::bind_front_wrapper< } // std +//------------------------------------------------------------------------------ + #endif diff --git a/include/boost/beast/core/detail/config.hpp b/include/boost/beast/core/detail/config.hpp index 60243e42..a96092f4 100644 --- a/include/boost/beast/core/detail/config.hpp +++ b/include/boost/beast/core/detail/config.hpp @@ -10,11 +10,9 @@ #ifndef BOOST_BEAST_CORE_DETAIL_CONFIG_HPP #define BOOST_BEAST_CORE_DETAIL_CONFIG_HPP -#include -#include - // Available to every header #include +#include #include #include @@ -69,6 +67,10 @@ namespace net = boost::asio; # endif #endif -#define BOOST_BEAST_DECL inline +#if BOOST_BEAST_DOXYGEN +# define BOOST_BEAST_DECL +#else +# define BOOST_BEAST_DECL inline +#endif #endif diff --git a/include/boost/beast/core/detail/impl/read.hpp b/include/boost/beast/core/detail/impl/read.hpp index 89a209e1..f9b4d53a 100644 --- a/include/boost/beast/core/detail/impl/read.hpp +++ b/include/boost/beast/core/detail/impl/read.hpp @@ -12,6 +12,9 @@ #include #include +#include +#include +#include namespace boost { namespace beast { @@ -431,7 +434,7 @@ read( void(error_code&, std::size_t, DynamicBuffer&)>::value, "CompletionCondition requirements not met"); error_code ec; - auto const bytes_transferred = read( + auto const bytes_transferred = detail::read( stream, buffer, std::move(cond), ec); if(ec) BOOST_THROW_EXCEPTION(system_error{ec}); diff --git a/include/boost/beast/core/detail/ostream.hpp b/include/boost/beast/core/detail/ostream.hpp index 19619834..6a9d7472 100644 --- a/include/boost/beast/core/detail/ostream.hpp +++ b/include/boost/beast/core/detail/ostream.hpp @@ -11,6 +11,7 @@ #define BOOST_BEAST_DETAIL_OSTREAM_HPP #include +#include #include #include #include diff --git a/include/boost/beast/core/detail/static_string.hpp b/include/boost/beast/core/detail/static_string.hpp index a5384591..c4af2077 100644 --- a/include/boost/beast/core/detail/static_string.hpp +++ b/include/boost/beast/core/detail/static_string.hpp @@ -41,24 +41,22 @@ lexicographical_compare( } template -inline int lexicographical_compare( basic_string_view s1, CharT const* s2, std::size_t n2) { - return lexicographical_compare( - s1.data(), s1.size(), s2, n2); + return detail::lexicographical_compare< + CharT, Traits>(s1.data(), s1.size(), s2, n2); } template -inline int lexicographical_compare( basic_string_view s1, basic_string_view s2) { - return lexicographical_compare( + return detail::lexicographical_compare( s1.data(), s1.size(), s2.data(), s2.size()); } diff --git a/include/boost/beast/core/detail/stream_algorithm.hpp b/include/boost/beast/core/detail/stream_algorithm.hpp index f531c629..029492d6 100644 --- a/include/boost/beast/core/detail/stream_algorithm.hpp +++ b/include/boost/beast/core/detail/stream_algorithm.hpp @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include diff --git a/include/boost/beast/core/detail/lean_tuple.hpp b/include/boost/beast/core/detail/tuple.hpp similarity index 73% rename from include/boost/beast/core/detail/lean_tuple.hpp rename to include/boost/beast/core/detail/tuple.hpp index 9539844b..cb64b8b3 100644 --- a/include/boost/beast/core/detail/lean_tuple.hpp +++ b/include/boost/beast/core/detail/tuple.hpp @@ -7,8 +7,8 @@ // Official repository: https://github.com/boostorg/beast // -#ifndef BOOST_BEAST_DETAIL_LEAN_TUPLE_HPP -#define BOOST_BEAST_DETAIL_LEAN_TUPLE_HPP +#ifndef BOOST_BEAST_DETAIL_TUPLE_HPP +#define BOOST_BEAST_DETAIL_TUPLE_HPP #include #include @@ -22,33 +22,33 @@ namespace beast { namespace detail { template -struct lean_tuple_element +struct tuple_element_impl { T t; }; template -struct lean_tuple_impl; +struct tuple_impl; template -struct lean_tuple_impl< +struct tuple_impl< boost::mp11::index_sequence, Ts...> - : lean_tuple_element... + : tuple_element_impl... { template - explicit lean_tuple_impl(Us&&... us) - : lean_tuple_element{std::forward(us)}... + explicit tuple_impl(Us&&... us) + : tuple_element_impl{std::forward(us)}... { } }; template -struct lean_tuple : lean_tuple_impl< +struct tuple : tuple_impl< boost::mp11::index_sequence_for, Ts...> { template - explicit lean_tuple(Us&&... us) - : lean_tuple_impl< + explicit tuple(Us&&... us) + : tuple_impl< boost::mp11::index_sequence_for, Ts...>{ std::forward(us)...} { @@ -57,21 +57,21 @@ struct lean_tuple : lean_tuple_impl< template T& -get(lean_tuple_element& te) +get(tuple_element_impl& te) { return te.t; } template T const& -get(lean_tuple_element const& te) +get(tuple_element_impl const& te) { return te.t; } template T&& -get(lean_tuple_element&& te) +get(tuple_element_impl&& te) { return std::move(te.t); } diff --git a/include/boost/beast/core/file.hpp b/include/boost/beast/core/file.hpp index 09c8e820..bb1ed7bc 100644 --- a/include/boost/beast/core/file.hpp +++ b/include/boost/beast/core/file.hpp @@ -15,7 +15,6 @@ #include #include #include -#include namespace boost { namespace beast { diff --git a/include/boost/beast/core/file_posix.hpp b/include/boost/beast/core/file_posix.hpp index 65bac206..c0addcde 100644 --- a/include/boost/beast/core/file_posix.hpp +++ b/include/boost/beast/core/file_posix.hpp @@ -10,7 +10,7 @@ #ifndef BOOST_BEAST_CORE_FILE_POSIX_HPP #define BOOST_BEAST_CORE_FILE_POSIX_HPP -#include +#include #if ! defined(BOOST_BEAST_NO_POSIX_FILE) # if ! defined(__APPLE__) && ! defined(__linux__) @@ -54,6 +54,7 @@ public: If the file is open it is first closed. */ + BOOST_BEAST_DECL ~file_posix(); /** Constructor @@ -66,12 +67,14 @@ public: The moved-from object behaves as if default constructed. */ + BOOST_BEAST_DECL file_posix(file_posix&& other); /** Assignment The moved-from object behaves as if default constructed. */ + BOOST_BEAST_DECL file_posix& operator=(file_posix&& other); /// Returns the native handle associated with the file. @@ -87,6 +90,7 @@ public: @param fd The native file handle to assign. */ + BOOST_BEAST_DECL void native_handle(native_handle_type fd); @@ -101,6 +105,7 @@ public: @param ec Set to the error, if any occurred. */ + BOOST_BEAST_DECL void close(error_code& ec); @@ -112,6 +117,7 @@ public: @param ec Set to the error, if any occurred */ + BOOST_BEAST_DECL void open(char const* path, file_mode mode, error_code& ec); @@ -121,6 +127,7 @@ public: @return The size in bytes */ + BOOST_BEAST_DECL std::uint64_t size(error_code& ec) const; @@ -130,6 +137,7 @@ public: @return The offset in bytes from the beginning of the file */ + BOOST_BEAST_DECL std::uint64_t pos(error_code& ec) const; @@ -139,6 +147,7 @@ public: @param ec Set to the error, if any occurred */ + BOOST_BEAST_DECL void seek(std::uint64_t offset, error_code& ec); @@ -150,6 +159,7 @@ public: @param ec Set to the error, if any occurred */ + BOOST_BEAST_DECL std::size_t read(void* buffer, std::size_t n, error_code& ec) const; @@ -161,6 +171,7 @@ public: @param ec Set to the error, if any occurred */ + BOOST_BEAST_DECL std::size_t write(void const* buffer, std::size_t n, error_code& ec); }; @@ -168,7 +179,7 @@ public: } // beast } // boost -#include +#include #endif diff --git a/include/boost/beast/core/file_stdio.hpp b/include/boost/beast/core/file_stdio.hpp index 09ca0c42..836905b7 100644 --- a/include/boost/beast/core/file_stdio.hpp +++ b/include/boost/beast/core/file_stdio.hpp @@ -39,6 +39,7 @@ public: If the file is open it is first closed. */ + BOOST_BEAST_DECL ~file_stdio(); /** Constructor @@ -51,12 +52,14 @@ public: The moved-from object behaves as if default constructed. */ + BOOST_BEAST_DECL file_stdio(file_stdio&& other); /** Assignment The moved-from object behaves as if default constructed. */ + BOOST_BEAST_DECL file_stdio& operator=(file_stdio&& other); /// Returns the native handle associated with the file. @@ -72,6 +75,7 @@ public: @param f The native file handle to assign. */ + BOOST_BEAST_DECL void native_handle(FILE* f); @@ -86,6 +90,7 @@ public: @param ec Set to the error, if any occurred. */ + BOOST_BEAST_DECL void close(error_code& ec); @@ -97,6 +102,7 @@ public: @param ec Set to the error, if any occurred */ + BOOST_BEAST_DECL void open(char const* path, file_mode mode, error_code& ec); @@ -106,6 +112,7 @@ public: @return The size in bytes */ + BOOST_BEAST_DECL std::uint64_t size(error_code& ec) const; @@ -115,6 +122,7 @@ public: @return The offset in bytes from the beginning of the file */ + BOOST_BEAST_DECL std::uint64_t pos(error_code& ec) const; @@ -124,6 +132,7 @@ public: @param ec Set to the error, if any occurred */ + BOOST_BEAST_DECL void seek(std::uint64_t offset, error_code& ec); @@ -135,6 +144,7 @@ public: @param ec Set to the error, if any occurred */ + BOOST_BEAST_DECL std::size_t read(void* buffer, std::size_t n, error_code& ec) const; @@ -146,6 +156,7 @@ public: @param ec Set to the error, if any occurred */ + BOOST_BEAST_DECL std::size_t write(void const* buffer, std::size_t n, error_code& ec); }; @@ -153,6 +164,6 @@ public: } // beast } // boost -#include +#include #endif diff --git a/include/boost/beast/core/file_win32.hpp b/include/boost/beast/core/file_win32.hpp index 3e9a18ab..5a5c6ab0 100644 --- a/include/boost/beast/core/file_win32.hpp +++ b/include/boost/beast/core/file_win32.hpp @@ -10,7 +10,7 @@ #ifndef BOOST_BEAST_CORE_FILE_WIN32_HPP #define BOOST_BEAST_CORE_FILE_WIN32_HPP -#include +#include #if ! defined(BOOST_BEAST_USE_WIN32_FILE) # ifdef BOOST_MSVC @@ -56,6 +56,7 @@ public: If the file is open it is first closed. */ + BOOST_BEAST_DECL ~file_win32(); /** Constructor @@ -68,12 +69,14 @@ public: The moved-from object behaves as if default constructed. */ + BOOST_BEAST_DECL file_win32(file_win32&& other); /** Assignment The moved-from object behaves as if default constructed. */ + BOOST_BEAST_DECL file_win32& operator=(file_win32&& other); /// Returns the native handle associated with the file. @@ -89,6 +92,7 @@ public: @param h The native file handle to assign. */ + BOOST_BEAST_DECL void native_handle(native_handle_type h); @@ -103,6 +107,7 @@ public: @param ec Set to the error, if any occurred. */ + BOOST_BEAST_DECL void close(error_code& ec); @@ -114,6 +119,7 @@ public: @param ec Set to the error, if any occurred */ + BOOST_BEAST_DECL void open(char const* path, file_mode mode, error_code& ec); @@ -123,6 +129,7 @@ public: @return The size in bytes */ + BOOST_BEAST_DECL std::uint64_t size(error_code& ec) const; @@ -132,6 +139,7 @@ public: @return The offset in bytes from the beginning of the file */ + BOOST_BEAST_DECL std::uint64_t pos(error_code& ec); @@ -141,6 +149,7 @@ public: @param ec Set to the error, if any occurred */ + BOOST_BEAST_DECL void seek(std::uint64_t offset, error_code& ec); @@ -152,6 +161,7 @@ public: @param ec Set to the error, if any occurred */ + BOOST_BEAST_DECL std::size_t read(void* buffer, std::size_t n, error_code& ec); @@ -163,6 +173,7 @@ public: @param ec Set to the error, if any occurred */ + BOOST_BEAST_DECL std::size_t write(void const* buffer, std::size_t n, error_code& ec); }; @@ -170,7 +181,7 @@ public: } // beast } // boost -#include +#include #endif diff --git a/include/boost/beast/core/flat_buffer.hpp b/include/boost/beast/core/flat_buffer.hpp index 76438d5e..1227f97e 100644 --- a/include/boost/beast/core/flat_buffer.hpp +++ b/include/boost/beast/core/flat_buffer.hpp @@ -73,7 +73,7 @@ class basic_flat_buffer std::is_nothrow_default_constructible::value; using alloc_traits = - detail::allocator_traits; + beast::detail::allocator_traits; using pocma = typename alloc_traits::propagate_on_container_move_assignment; @@ -516,6 +516,6 @@ using flat_buffer = } // beast } // boost -#include +#include #endif diff --git a/include/boost/beast/core/flat_static_buffer.hpp b/include/boost/beast/core/flat_static_buffer.hpp index 9c1f6359..d993181a 100644 --- a/include/boost/beast/core/flat_static_buffer.hpp +++ b/include/boost/beast/core/flat_static_buffer.hpp @@ -77,7 +77,7 @@ public: } /// Change the number of readable and writable bytes to zero. - inline + BOOST_BEAST_DECL void clear() noexcept; @@ -168,7 +168,7 @@ public: Strong guarantee. */ - inline + BOOST_BEAST_DECL mutable_buffers_type prepare(std::size_t n); @@ -211,7 +211,7 @@ public: No-throw guarantee. */ - inline + BOOST_BEAST_DECL void consume(std::size_t n) noexcept; @@ -239,7 +239,7 @@ protected: No-throw guarantee. */ - inline + BOOST_BEAST_DECL void reset(void* p, std::size_t n) noexcept; @@ -318,6 +318,6 @@ public: } // beast } // boost -#include +#include #endif \ No newline at end of file diff --git a/include/boost/beast/core/handler_ptr.hpp b/include/boost/beast/core/handler_ptr.hpp index e4117cc8..d758e060 100644 --- a/include/boost/beast/core/handler_ptr.hpp +++ b/include/boost/beast/core/handler_ptr.hpp @@ -118,14 +118,14 @@ public: /// Return a reference to the handler handler_type const& - handler() const + handler() const noexcept { return h_; } /// Return a reference to the handler handler_type& - handler() + handler() noexcept { return h_; } @@ -165,6 +165,7 @@ public: T* operator->() const { + BOOST_ASSERT(t_); return t_; } @@ -211,6 +212,6 @@ public: } // beast } // boost -#include +#include #endif diff --git a/include/boost/beast/core/impl/buffered_read_stream.ipp b/include/boost/beast/core/impl/buffered_read_stream.hpp similarity index 87% rename from include/boost/beast/core/impl/buffered_read_stream.ipp rename to include/boost/beast/core/impl/buffered_read_stream.hpp index 00d96f71..a2de635e 100644 --- a/include/boost/beast/core/impl/buffered_read_stream.ipp +++ b/include/boost/beast/core/impl/buffered_read_stream.hpp @@ -7,8 +7,8 @@ // Official repository: https://github.com/boostorg/beast // -#ifndef BOOST_BEAST_IMPL_BUFFERED_READ_STREAM_IPP -#define BOOST_BEAST_IMPL_BUFFERED_READ_STREAM_IPP +#ifndef BOOST_BEAST_IMPL_BUFFERED_READ_STREAM_HPP +#define BOOST_BEAST_IMPL_BUFFERED_READ_STREAM_HPP #include #include @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -54,44 +55,65 @@ public: { } + void + operator()(error_code ec, + std::size_t bytes_transferred); + + // + using allocator_type = net::associated_allocator_t; - allocator_type - get_allocator() const noexcept - { - return (net::get_associated_allocator)(h_); - } - using executor_type = net::associated_executor_t().get_executor())>; + allocator_type + get_allocator() const noexcept + { + return net::get_associated_allocator(h_); + } + executor_type get_executor() const noexcept { - return (net::get_associated_executor)( + return net::get_associated_executor( h_, s_.get_executor()); } - void - operator()(error_code const& ec, - std::size_t bytes_transferred); + template + friend + void asio_handler_invoke( + Function&& f, read_some_op* op) + { + using net::asio_handler_invoke; + asio_handler_invoke(f, std::addressof(op->h_)); + } + + friend + void* asio_handler_allocate( + std::size_t size, read_some_op* op) + { + using net::asio_handler_allocate; + return asio_handler_allocate( + size, std::addressof(op->h_)); + } + + friend + void asio_handler_deallocate( + void* p, std::size_t size, read_some_op* op) + { + using net::asio_handler_deallocate; + asio_handler_deallocate( + p, size, std::addressof(op->h_)); + } friend bool asio_handler_is_continuation(read_some_op* op) { using net::asio_handler_is_continuation; return asio_handler_is_continuation( - std::addressof(op->h_)); - } - - template - friend - void asio_handler_invoke(Function&& f, read_some_op* op) - { - using net::asio_handler_invoke; - asio_handler_invoke(f, std::addressof(op->h_)); + std::addressof(op->h_)); } }; @@ -99,8 +121,9 @@ template template void buffered_read_stream:: -read_some_op::operator()( - error_code const& ec, std::size_t bytes_transferred) +read_some_op:: +operator()( + error_code ec, std::size_t bytes_transferred) { switch(step_) { @@ -114,19 +137,18 @@ read_some_op::operator()( return s_.next_layer_.async_read_some( b_, std::move(*this)); } - // read step_ = 2; return s_.next_layer_.async_read_some( s_.buffer_.prepare(read_size( s_.buffer_, s_.capacity_)), std::move(*this)); - } step_ = 3; return net::post( s_.get_executor(), - beast::bind_front_handler(std::move(*this), ec, 0)); + beast::bind_front_handler( + std::move(*this), ec, 0)); case 1: // upcall @@ -221,7 +243,7 @@ read_some(MutableBufferSequence const& buffers, } else { - ec.assign(0, ec.category()); + ec = {}; } auto bytes_transferred = buffer_copy(buffers, buffer_.data()); diff --git a/include/boost/beast/core/impl/buffers_adapter.ipp b/include/boost/beast/core/impl/buffers_adapter.hpp similarity index 97% rename from include/boost/beast/core/impl/buffers_adapter.ipp rename to include/boost/beast/core/impl/buffers_adapter.hpp index b8eeb82c..8d7415d6 100644 --- a/include/boost/beast/core/impl/buffers_adapter.ipp +++ b/include/boost/beast/core/impl/buffers_adapter.hpp @@ -308,7 +308,6 @@ private: }; template -inline auto buffers_adapter:: mutable_buffers_type:: @@ -319,7 +318,6 @@ begin() const -> } template -inline auto buffers_adapter:: mutable_buffers_type:: @@ -479,19 +477,27 @@ prepare(std::size_t n) -> return mutable_buffers_type{*this}; } +template +auto +buffers_adapter:: +data() const noexcept -> + const_buffers_type +{ + return const_buffers_type{*this}; +} + template void buffers_adapter:: -commit(std::size_t n) +commit(std::size_t n) noexcept { - using net::buffer_size; if(out_ == end_) return; auto const last = std::prev(end_); while(out_ != last) { auto const avail = - buffer_size(*out_) - out_pos_; + net::buffer_size(*out_) - out_pos_; if(n < avail) { out_pos_ += n; @@ -504,10 +510,11 @@ commit(std::size_t n) in_size_ += avail; } - n = (std::min)(n, out_end_ - out_pos_); + n = std::min( + n, out_end_ - out_pos_); out_pos_ += n; in_size_ += n; - if(out_pos_ == buffer_size(*out_)) + if(out_pos_ == net::buffer_size(*out_)) { ++out_; out_pos_ = 0; @@ -515,26 +522,15 @@ commit(std::size_t n) } } -template -inline -auto -buffers_adapter:: -data() const -> - const_buffers_type -{ - return const_buffers_type{*this}; -} - template void buffers_adapter:: -consume(std::size_t n) +consume(std::size_t n) noexcept { - using net::buffer_size; while(begin_ != out_) { auto const avail = - buffer_size(*begin_) - in_pos_; + net::buffer_size(*begin_) - in_pos_; if(n < avail) { in_size_ -= n; diff --git a/include/boost/beast/core/impl/buffers_cat.ipp b/include/boost/beast/core/impl/buffers_cat.hpp similarity index 95% rename from include/boost/beast/core/impl/buffers_cat.ipp rename to include/boost/beast/core/impl/buffers_cat.hpp index b1b5ec2e..bd762bf7 100644 --- a/include/boost/beast/core/impl/buffers_cat.ipp +++ b/include/boost/beast/core/impl/buffers_cat.hpp @@ -7,10 +7,10 @@ // Official repository: https://github.com/boostorg/beast // -#ifndef BOOST_BEAST_IMPL_BUFFERS_CAT_IPP -#define BOOST_BEAST_IMPL_BUFFERS_CAT_IPP +#ifndef BOOST_BEAST_IMPL_BUFFERS_CAT_HPP +#define BOOST_BEAST_IMPL_BUFFERS_CAT_HPP -#include +#include #include #include #include @@ -57,7 +57,7 @@ class buffers_cat_view::const_iterator static_assert(sizeof...(Bn) >= 2, "A minimum of two sequences are required"); - detail::lean_tuple const* bn_ = nullptr; + detail::tuple const* bn_ = nullptr; detail::variant::type..., past_end> it_; @@ -113,7 +113,7 @@ public: private: const_iterator( - detail::lean_tuple const& bn, bool at_end); + detail::tuple const& bn, bool at_end); template void @@ -260,7 +260,7 @@ template buffers_cat_view:: const_iterator:: const_iterator( - detail::lean_tuple const& bn, bool at_end) + detail::tuple const& bn, bool at_end) : bn_(&bn) { if(! at_end) @@ -375,7 +375,7 @@ buffers_cat_view::begin() const -> template inline auto -buffers_cat_view::end() const -> +buffers_cat_view::end() const-> const_iterator { return const_iterator{bn_, true}; diff --git a/include/boost/beast/core/impl/buffers_prefix.ipp b/include/boost/beast/core/impl/buffers_prefix.hpp similarity index 100% rename from include/boost/beast/core/impl/buffers_prefix.ipp rename to include/boost/beast/core/impl/buffers_prefix.hpp diff --git a/include/boost/beast/core/impl/buffers_suffix.ipp b/include/boost/beast/core/impl/buffers_suffix.hpp similarity index 87% rename from include/boost/beast/core/impl/buffers_suffix.ipp rename to include/boost/beast/core/impl/buffers_suffix.hpp index 2d06afe3..06957b11 100644 --- a/include/boost/beast/core/impl/buffers_suffix.ipp +++ b/include/boost/beast/core/impl/buffers_suffix.hpp @@ -7,8 +7,8 @@ // Official repository: https://github.com/boostorg/beast // -#ifndef BOOST_BEAST_IMPL_BUFFERS_SUFFIX_IPP -#define BOOST_BEAST_IMPL_BUFFERS_SUFFIX_IPP +#ifndef BOOST_BEAST_IMPL_BUFFERS_SUFFIX_HPP +#define BOOST_BEAST_IMPL_BUFFERS_SUFFIX_HPP #include #include @@ -135,16 +135,6 @@ buffers_suffix() { } -template -buffers_suffix:: -buffers_suffix(buffers_suffix&& other) - : buffers_suffix(std::move(other), - std::distance( - net::buffer_sequence_begin( - other.bs_), other.begin_)) -{ -} - template buffers_suffix:: buffers_suffix(buffers_suffix const& other) @@ -181,23 +171,6 @@ buffers_suffix(boost::in_place_init_t, Args&&... args) "Buffers not constructible from arguments"); } -template -auto -buffers_suffix:: -operator=(buffers_suffix&& other) -> - buffers_suffix& -{ - auto const dist = std::distance( - net::buffer_sequence_begin(other.bs_), - other.begin_); - bs_ = std::move(other.bs_); - begin_ = std::next( - net::buffer_sequence_begin(bs_), - dist); - skip_ = other.skip_; - return *this; -} - template auto buffers_suffix:: @@ -215,7 +188,6 @@ operator=(buffers_suffix const& other) -> } template -inline auto buffers_suffix:: begin() const -> @@ -225,7 +197,6 @@ begin() const -> } template -inline auto buffers_suffix:: end() const -> diff --git a/include/boost/beast/core/impl/file_posix.ipp b/include/boost/beast/core/impl/file_posix.hpp similarity index 88% rename from include/boost/beast/core/impl/file_posix.ipp rename to include/boost/beast/core/impl/file_posix.hpp index 9fc94474..2533bfe4 100644 --- a/include/boost/beast/core/impl/file_posix.ipp +++ b/include/boost/beast/core/impl/file_posix.hpp @@ -7,8 +7,8 @@ // Official repository: https://github.com/boostorg/beast // -#ifndef BOOST_BEAST_CORE_IMPL_FILE_POSIX_IPP -#define BOOST_BEAST_CORE_IMPL_FILE_POSIX_IPP +#ifndef BOOST_BEAST_CORE_IMPL_FILE_POSIX_HPP +#define BOOST_BEAST_CORE_IMPL_FILE_POSIX_HPP #if ! defined(BOOST_BEAST_NO_POSIX_FADVISE) # if defined(__APPLE__) || (defined(ANDROID) && (__ANDROID_API__ < 21)) @@ -55,7 +55,6 @@ file_posix_close(int fd) } // detail -inline file_posix:: ~file_posix() { @@ -63,14 +62,12 @@ file_posix:: detail::file_posix_close(fd_); } -inline file_posix:: file_posix(file_posix&& other) : fd_(boost::exchange(other.fd_, -1)) { } -inline file_posix& file_posix:: operator=(file_posix&& other) @@ -84,7 +81,6 @@ operator=(file_posix&& other) return *this; } -inline void file_posix:: native_handle(native_handle_type fd) @@ -94,7 +90,6 @@ native_handle(native_handle_type fd) fd_ = fd; } -inline void file_posix:: close(error_code& ec) @@ -104,18 +99,17 @@ close(error_code& ec) auto const ev = detail::file_posix_close(fd_); if(ev) - ec.assign(ev, generic_category()); + ec.assign(ev, system_category()); else - ec.assign(0, ec.category()); + ec = {}; fd_ = -1; } else { - ec.assign(0, ec.category()); + ec = {}; } } -inline void file_posix:: open(char const* path, file_mode mode, error_code& ec) @@ -125,9 +119,9 @@ open(char const* path, file_mode mode, error_code& ec) auto const ev = detail::file_posix_close(fd_); if(ev) - ec.assign(ev, generic_category()); + ec.assign(ev, system_category()); else - ec.assign(0, ec.category()); + ec = {}; fd_ = -1; } int f = 0; @@ -200,7 +194,7 @@ open(char const* path, file_mode mode, error_code& ec) auto const ev = errno; if(ev != EINTR) { - ec.assign(ev, generic_category()); + ec.assign(ev, system_category()); return; } } @@ -210,14 +204,13 @@ open(char const* path, file_mode mode, error_code& ec) auto const ev = errno; detail::file_posix_close(fd_); fd_ = -1; - ec.assign(ev, generic_category()); + ec.assign(ev, system_category()); return; } #endif - ec.assign(0, ec.category()); + ec = {}; } -inline std::uint64_t file_posix:: size(error_code& ec) const @@ -230,14 +223,13 @@ size(error_code& ec) const struct stat st; if(::fstat(fd_, &st) != 0) { - ec.assign(errno, generic_category()); + ec.assign(errno, system_category()); return 0; } - ec.assign(0, ec.category()); + ec = {}; return st.st_size; } -inline std::uint64_t file_posix:: pos(error_code& ec) const @@ -250,14 +242,13 @@ pos(error_code& ec) const auto const result = ::lseek(fd_, 0, SEEK_CUR); if(result == (off_t)-1) { - ec.assign(errno, generic_category()); + ec.assign(errno, system_category()); return 0; } - ec.assign(0, ec.category()); + ec = {}; return result; } -inline void file_posix:: seek(std::uint64_t offset, error_code& ec) @@ -270,13 +261,12 @@ seek(std::uint64_t offset, error_code& ec) auto const result = ::lseek(fd_, offset, SEEK_SET); if(result == static_cast(-1)) { - ec.assign(errno, generic_category()); + ec.assign(errno, system_category()); return; } - ec.assign(0, ec.category()); + ec = {}; } -inline std::size_t file_posix:: read(void* buffer, std::size_t n, error_code& ec) const @@ -297,7 +287,7 @@ read(void* buffer, std::size_t n, error_code& ec) const auto const ev = errno; if(ev == EINTR) continue; - ec.assign(ev, generic_category()); + ec.assign(ev, system_category()); return nread; } if(result == 0) @@ -312,7 +302,6 @@ read(void* buffer, std::size_t n, error_code& ec) const return nread; } -inline std::size_t file_posix:: write(void const* buffer, std::size_t n, error_code& ec) @@ -333,7 +322,7 @@ write(void const* buffer, std::size_t n, error_code& ec) auto const ev = errno; if(ev == EINTR) continue; - ec.assign(ev, generic_category()); + ec.assign(ev, system_category()); return nwritten; } n -= result; diff --git a/include/boost/beast/core/impl/file_stdio.ipp b/include/boost/beast/core/impl/file_stdio.hpp similarity index 92% rename from include/boost/beast/core/impl/file_stdio.ipp rename to include/boost/beast/core/impl/file_stdio.hpp index 853b1403..339d07b3 100644 --- a/include/boost/beast/core/impl/file_stdio.ipp +++ b/include/boost/beast/core/impl/file_stdio.hpp @@ -7,8 +7,8 @@ // Official repository: https://github.com/boostorg/beast // -#ifndef BOOST_BEAST_CORE_IMPL_FILE_STDIO_IPP -#define BOOST_BEAST_CORE_IMPL_FILE_STDIO_IPP +#ifndef BOOST_BEAST_CORE_IMPL_FILE_STDIO_HPP +#define BOOST_BEAST_CORE_IMPL_FILE_STDIO_HPP #include #include @@ -16,7 +16,6 @@ namespace boost { namespace beast { -inline file_stdio:: ~file_stdio() { @@ -24,14 +23,12 @@ file_stdio:: fclose(f_); } -inline file_stdio:: file_stdio(file_stdio&& other) : f_(boost::exchange(other.f_, nullptr)) { } -inline file_stdio& file_stdio:: operator=(file_stdio&& other) @@ -45,7 +42,6 @@ operator=(file_stdio&& other) return *this; } -inline void file_stdio:: native_handle(FILE* f) @@ -55,7 +51,6 @@ native_handle(FILE* f) f_ = f; } -inline void file_stdio:: close(error_code& ec) @@ -70,10 +65,9 @@ close(error_code& ec) return; } } - ec.assign(0, ec.category()); + ec = {}; } -inline void file_stdio:: open(char const* path, file_mode mode, error_code& ec) @@ -112,10 +106,9 @@ open(char const* path, file_mode mode, error_code& ec) return; } #endif - ec.assign(0, ec.category()); + ec = {}; } -inline std::uint64_t file_stdio:: size(error_code& ec) const @@ -148,11 +141,10 @@ size(error_code& ec) const if(result != 0) ec.assign(errno, generic_category()); else - ec.assign(0, ec.category()); + ec = {}; return size; } -inline std::uint64_t file_stdio:: pos(error_code& ec) const @@ -168,11 +160,10 @@ pos(error_code& ec) const ec.assign(errno, generic_category()); return 0; } - ec.assign(0, ec.category()); + ec = {}; return pos; } -inline void file_stdio:: seek(std::uint64_t offset, error_code& ec) @@ -192,10 +183,9 @@ seek(std::uint64_t offset, error_code& ec) if(result != 0) ec.assign(errno, generic_category()); else - ec.assign(0, ec.category()); + ec = {}; } -inline std::size_t file_stdio:: read(void* buffer, std::size_t n, error_code& ec) const @@ -214,7 +204,6 @@ read(void* buffer, std::size_t n, error_code& ec) const return nread; } -inline std::size_t file_stdio:: write(void const* buffer, std::size_t n, error_code& ec) diff --git a/include/boost/beast/core/impl/file_win32.ipp b/include/boost/beast/core/impl/file_win32.hpp similarity index 94% rename from include/boost/beast/core/impl/file_win32.ipp rename to include/boost/beast/core/impl/file_win32.hpp index a8eb7fdc..a7ea3626 100644 --- a/include/boost/beast/core/impl/file_win32.ipp +++ b/include/boost/beast/core/impl/file_win32.hpp @@ -7,8 +7,8 @@ // Official repository: https://github.com/boostorg/beast // -#ifndef BOOST_BEAST_CORE_IMPL_FILE_WIN32_IPP -#define BOOST_BEAST_CORE_IMPL_FILE_WIN32_IPP +#ifndef BOOST_BEAST_CORE_IMPL_FILE_WIN32_HPP +#define BOOST_BEAST_CORE_IMPL_FILE_WIN32_HPP #include #include @@ -51,7 +51,6 @@ set_file_pointer_ex( } // detail -inline file_win32:: ~file_win32() { @@ -59,14 +58,13 @@ file_win32:: boost::winapi::CloseHandle(h_); } -inline file_win32:: file_win32(file_win32&& other) - : h_(boost::exchange(other.h_, boost::winapi::INVALID_HANDLE_VALUE_)) + : h_(boost::exchange(other.h_, + boost::winapi::INVALID_HANDLE_VALUE_)) { } -inline file_win32& file_win32:: operator=(file_win32&& other) @@ -80,7 +78,6 @@ operator=(file_win32&& other) return *this; } -inline void file_win32:: native_handle(native_handle_type h) @@ -90,7 +87,6 @@ native_handle(native_handle_type h) h_ = h; } -inline void file_win32:: close(error_code& ec) @@ -101,16 +97,15 @@ close(error_code& ec) ec.assign(boost::winapi::GetLastError(), system_category()); else - ec.assign(0, ec.category()); + ec = {}; h_ = boost::winapi::INVALID_HANDLE_VALUE_; } else { - ec.assign(0, ec.category()); + ec = {}; } } -inline void file_win32:: open(char const* path, file_mode mode, error_code& ec) @@ -206,10 +201,9 @@ open(char const* path, file_mode mode, error_code& ec) ec.assign(boost::winapi::GetLastError(), system_category()); else - ec.assign(0, ec.category()); + ec = {}; } -inline std::uint64_t file_win32:: size(error_code& ec) const @@ -226,11 +220,10 @@ size(error_code& ec) const system_category()); return 0; } - ec.assign(0, ec.category()); + ec = {}; return fileSize.QuadPart; } -inline std::uint64_t file_win32:: pos(error_code& ec) @@ -250,11 +243,10 @@ pos(error_code& ec) system_category()); return 0; } - ec.assign(0, ec.category()); + ec = {}; return out.QuadPart; } -inline void file_win32:: seek(std::uint64_t offset, error_code& ec) @@ -273,10 +265,9 @@ seek(std::uint64_t offset, error_code& ec) system_category()); return; } - ec.assign(0, ec.category()); + ec = {}; } -inline std::size_t file_win32:: read(void* buffer, std::size_t n, error_code& ec) @@ -304,7 +295,7 @@ read(void* buffer, std::size_t n, error_code& ec) if(dwError != boost::winapi::ERROR_HANDLE_EOF_) ec.assign(dwError, system_category()); else - ec.assign(0, ec.category()); + ec = {}; return nread; } if(bytesRead == 0) @@ -313,11 +304,10 @@ read(void* buffer, std::size_t n, error_code& ec) nread += bytesRead; buffer = static_cast(buffer) + bytesRead; } - ec.assign(0, ec.category()); + ec = {}; return nread; } -inline std::size_t file_win32:: write(void const* buffer, std::size_t n, error_code& ec) @@ -345,7 +335,7 @@ write(void const* buffer, std::size_t n, error_code& ec) if(dwError != boost::winapi::ERROR_HANDLE_EOF_) ec.assign(dwError, system_category()); else - ec.assign(0, ec.category()); + ec = {}; return nwritten; } if(bytesWritten == 0) @@ -354,7 +344,7 @@ write(void const* buffer, std::size_t n, error_code& ec) nwritten += bytesWritten; buffer = static_cast(buffer) + bytesWritten; } - ec.assign(0, ec.category()); + ec = {}; return nwritten; } diff --git a/include/boost/beast/core/impl/flat_buffer.ipp b/include/boost/beast/core/impl/flat_buffer.hpp similarity index 100% rename from include/boost/beast/core/impl/flat_buffer.ipp rename to include/boost/beast/core/impl/flat_buffer.hpp diff --git a/include/boost/beast/core/impl/flat_static_buffer.ipp b/include/boost/beast/core/impl/flat_static_buffer.hpp similarity index 96% rename from include/boost/beast/core/impl/flat_static_buffer.ipp rename to include/boost/beast/core/impl/flat_static_buffer.hpp index 2c291ca8..80722aee 100644 --- a/include/boost/beast/core/impl/flat_static_buffer.ipp +++ b/include/boost/beast/core/impl/flat_static_buffer.hpp @@ -7,8 +7,8 @@ // Official repository: https://github.com/boostorg/beast // -#ifndef BOOST_BEAST_IMPL_FLAT_STATIC_BUFFER_IPP -#define BOOST_BEAST_IMPL_FLAT_STATIC_BUFFER_IPP +#ifndef BOOST_BEAST_IMPL_FLAT_STATIC_BUFFER_HPP +#define BOOST_BEAST_IMPL_FLAT_STATIC_BUFFER_HPP #include #include diff --git a/include/boost/beast/core/impl/handler_ptr.ipp b/include/boost/beast/core/impl/handler_ptr.hpp similarity index 80% rename from include/boost/beast/core/impl/handler_ptr.ipp rename to include/boost/beast/core/impl/handler_ptr.hpp index 1c64da61..3007ac12 100644 --- a/include/boost/beast/core/impl/handler_ptr.ipp +++ b/include/boost/beast/core/impl/handler_ptr.hpp @@ -22,15 +22,15 @@ void handler_ptr:: clear() { - typename beast::detail::allocator_traits< + using A = typename detail::allocator_traits< net::associated_allocator_t< - Handler>>::template rebind_alloc alloc( - net::get_associated_allocator( - handler())); - beast::detail::allocator_traits< - decltype(alloc)>::destroy(alloc, t_); - beast::detail::allocator_traits< - decltype(alloc)>::deallocate(alloc, t_, 1); + Handler>>::template rebind_alloc; + using alloc_traits = + beast::detail::allocator_traits; + A alloc( + net::get_associated_allocator(handler())); + alloc_traits::destroy(alloc, t_); + alloc_traits::deallocate(alloc, t_, 1); t_ = nullptr; } @@ -65,22 +65,22 @@ handler_ptr:: handler_ptr(DeducedHandler&& h, Args&&... args) { BOOST_STATIC_ASSERT(! std::is_array::value); - using A = typename beast::detail::allocator_traits< + using A = typename detail::allocator_traits< net::associated_allocator_t< Handler>>::template rebind_alloc; + using alloc_traits = + beast::detail::allocator_traits; A alloc{net::get_associated_allocator(h)}; - using traits = - typename beast::detail::allocator_traits; bool destroy = false; auto deleter = [&alloc, &destroy](T* p) { if(destroy) - traits::destroy(alloc, p); - traits::deallocate(alloc, p, 1); + alloc_traits::destroy(alloc, p); + alloc_traits::deallocate(alloc, p, 1); }; std::unique_ptr t{ - traits::allocate(alloc, 1), deleter}; - traits::construct(alloc, t.get(), + alloc_traits::allocate(alloc, 1), deleter}; + alloc_traits::construct(alloc, t.get(), static_cast(h), std::forward(args)...); destroy = true; diff --git a/include/boost/beast/core/impl/multi_buffer.ipp b/include/boost/beast/core/impl/multi_buffer.hpp similarity index 99% rename from include/boost/beast/core/impl/multi_buffer.ipp rename to include/boost/beast/core/impl/multi_buffer.hpp index c826a156..f11b8303 100644 --- a/include/boost/beast/core/impl/multi_buffer.ipp +++ b/include/boost/beast/core/impl/multi_buffer.hpp @@ -7,8 +7,8 @@ // Official repository: https://github.com/boostorg/beast // -#ifndef BOOST_BEAST_IMPL_MULTI_BUFFER_IPP -#define BOOST_BEAST_IMPL_MULTI_BUFFER_IPP +#ifndef BOOST_BEAST_IMPL_MULTI_BUFFER_HPP +#define BOOST_BEAST_IMPL_MULTI_BUFFER_HPP #include #include diff --git a/include/boost/beast/core/impl/read_size.ipp b/include/boost/beast/core/impl/read_size.hpp similarity index 88% rename from include/boost/beast/core/impl/read_size.ipp rename to include/boost/beast/core/impl/read_size.hpp index fd75db04..bb015dc7 100644 --- a/include/boost/beast/core/impl/read_size.ipp +++ b/include/boost/beast/core/impl/read_size.hpp @@ -7,8 +7,8 @@ // Official repository: https://github.com/boostorg/beast // -#ifndef BOOST_BEAST_IMPL_READ_SIZE_IPP -#define BOOST_BEAST_IMPL_READ_SIZE_IPP +#ifndef BOOST_BEAST_IMPL_READ_SIZE_HPP +#define BOOST_BEAST_IMPL_READ_SIZE_HPP #include #include @@ -49,15 +49,14 @@ read_size(DynamicBuffer& buffer, auto const size = buffer.size(); auto const limit = buffer.max_size() - size; BOOST_ASSERT(size <= buffer.max_size()); - return (std::min)( - (std::max)(512, buffer.capacity() - size), - (std::min)(max_size, limit)); + return std::min( + std::max(512, buffer.capacity() - size), + std::min(max_size, limit)); } } // detail template -inline std::size_t read_size( DynamicBuffer& buffer, std::size_t max_size) diff --git a/include/boost/beast/core/impl/static_buffer.ipp b/include/boost/beast/core/impl/static_buffer.hpp similarity index 97% rename from include/boost/beast/core/impl/static_buffer.ipp rename to include/boost/beast/core/impl/static_buffer.hpp index ad47173f..68a3b129 100644 --- a/include/boost/beast/core/impl/static_buffer.ipp +++ b/include/boost/beast/core/impl/static_buffer.hpp @@ -7,8 +7,8 @@ // Official repository: https://github.com/boostorg/beast // -#ifndef BOOST_BEAST_IMPL_STATIC_BUFFER_IPP -#define BOOST_BEAST_IMPL_STATIC_BUFFER_IPP +#ifndef BOOST_BEAST_IMPL_STATIC_BUFFER_HPP +#define BOOST_BEAST_IMPL_STATIC_BUFFER_HPP #include #include diff --git a/include/boost/beast/core/impl/static_string.ipp b/include/boost/beast/core/impl/static_string.hpp similarity index 95% rename from include/boost/beast/core/impl/static_string.ipp rename to include/boost/beast/core/impl/static_string.hpp index 27274f4e..b32c08d4 100644 --- a/include/boost/beast/core/impl/static_string.ipp +++ b/include/boost/beast/core/impl/static_string.hpp @@ -7,8 +7,8 @@ // Official repository: https://github.com/boostorg/beast // -#ifndef BOOST_BEAST_IMPL_STATIC_STRING_IPP -#define BOOST_BEAST_IMPL_STATIC_STRING_IPP +#ifndef BOOST_BEAST_IMPL_STATIC_STRING_HPP +#define BOOST_BEAST_IMPL_STATIC_STRING_HPP #include #include @@ -65,7 +65,12 @@ template static_string:: static_string(CharT const* s) { - assign(s); + auto const count = Traits::length(s); + if(count > max_size()) + BOOST_THROW_EXCEPTION(std::length_error{ + "count > max_size()"}); + n_ = count; + Traits::copy(&s_[0], s, n_ + 1); } template @@ -117,6 +122,21 @@ static_string(T const& t, size_type pos, size_type n) // (assignment) // +template +auto +static_string:: +operator=(CharT const* s) -> + static_string& +{ + auto const count = Traits::length(s); + if(count > max_size()) + BOOST_THROW_EXCEPTION(std::length_error{ + "count > max_size()"}); + n_ = count; + Traits::copy(&s_[0], s, n_ + 1); + return *this; +} + template auto static_string:: @@ -465,6 +485,8 @@ resize(std::size_t n) if(n > max_size()) BOOST_THROW_EXCEPTION(std::length_error{ "n > max_size()"}); + if(n > n_) + Traits::assign(&s_[n_], n - n_, CharT{}); n_ = n; term(); } diff --git a/include/boost/beast/core/impl/string_param.ipp b/include/boost/beast/core/impl/string_param.hpp similarity index 96% rename from include/boost/beast/core/impl/string_param.ipp rename to include/boost/beast/core/impl/string_param.hpp index a60771cc..50c85928 100644 --- a/include/boost/beast/core/impl/string_param.ipp +++ b/include/boost/beast/core/impl/string_param.hpp @@ -7,8 +7,8 @@ // Official repository: https://github.com/boostorg/beast // -#ifndef BOOST_BEAST_IMPL_STRING_PARAM_IPP -#define BOOST_BEAST_IMPL_STRING_PARAM_IPP +#ifndef BOOST_BEAST_IMPL_STRING_PARAM_HPP +#define BOOST_BEAST_IMPL_STRING_PARAM_HPP namespace boost { namespace beast { diff --git a/include/boost/beast/core/multi_buffer.hpp b/include/boost/beast/core/multi_buffer.hpp index 0119b272..c345d137 100644 --- a/include/boost/beast/core/multi_buffer.hpp +++ b/include/boost/beast/core/multi_buffer.hpp @@ -82,7 +82,8 @@ class basic_multi_buffer template class readable_bytes; - using alloc_traits = detail::allocator_traits; + using alloc_traits = + beast::detail::allocator_traits; using list_type = typename boost::intrusive::make_list>::type; using iter = typename list_type::iterator; @@ -540,6 +541,6 @@ using multi_buffer = basic_multi_buffer>; } // beast } // boost -#include +#include #endif \ No newline at end of file diff --git a/include/boost/beast/core/read_size.hpp b/include/boost/beast/core/read_size.hpp index d9aaaa61..96324154 100644 --- a/include/boost/beast/core/read_size.hpp +++ b/include/boost/beast/core/read_size.hpp @@ -59,6 +59,6 @@ read_size_or_throw(DynamicBuffer& buffer, } // beast } // boost -#include +#include #endif diff --git a/include/boost/beast/core/static_buffer.hpp b/include/boost/beast/core/static_buffer.hpp index 17e23243..62d35676 100644 --- a/include/boost/beast/core/static_buffer.hpp +++ b/include/boost/beast/core/static_buffer.hpp @@ -305,6 +305,6 @@ public: } // beast } // boost -#include +#include #endif diff --git a/include/boost/beast/core/static_string.hpp b/include/boost/beast/core/static_string.hpp index 991c2e64..0ba61cf1 100644 --- a/include/boost/beast/core/static_string.hpp +++ b/include/boost/beast/core/static_string.hpp @@ -171,10 +171,7 @@ public: /// Assign from null-terminated string. static_string& - operator=(CharT const* s) - { - return assign(s); - } + operator=(CharT const* s); /// Assign from single character. static_string& @@ -1107,6 +1104,6 @@ to_static_string(Integer x); } // beast } // boost -#include +#include #endif diff --git a/include/boost/beast/core/string.hpp b/include/boost/beast/core/string.hpp index de94d2e6..8206f9d9 100644 --- a/include/boost/beast/core/string.hpp +++ b/include/boost/beast/core/string.hpp @@ -64,25 +64,25 @@ iequals( auto p1 = lhs.data(); auto p2 = rhs.data(); char a, b; + // fast loop while(n--) { a = *p1++; b = *p2++; if(a != b) - { - // slow loop - do - { - if(ascii_tolower(a) != ascii_tolower(b)) - return false; - a = *p1++; - b = *p2++; - } - while(n--); - return true; - } + goto slow; } return true; +slow: + do + { + if(ascii_tolower(a) != ascii_tolower(b)) + return false; + a = *p1++; + b = *p2++; + } + while(n--); + return true; } } // detail diff --git a/include/boost/beast/core/string_param.hpp b/include/boost/beast/core/string_param.hpp index a068cc40..4a057764 100644 --- a/include/boost/beast/core/string_param.hpp +++ b/include/boost/beast/core/string_param.hpp @@ -125,6 +125,6 @@ public: } // beast } // boost -#include +#include #endif diff --git a/test/beast/core/CMakeLists.txt b/test/beast/core/CMakeLists.txt index 456cbb99..830ea96e 100644 --- a/test/beast/core/CMakeLists.txt +++ b/test/beast/core/CMakeLists.txt @@ -46,9 +46,9 @@ add_executable (tests-beast-core string_param.cpp type_traits.cpp detail_read.cpp + detail_tuple.cpp detail/base64.cpp detail/clamp.cpp - detail/lean_tuple.cpp detail/sha1.cpp detail/variant.cpp detail/varint.cpp diff --git a/test/beast/core/Jamfile b/test/beast/core/Jamfile index b3e1eb2c..c407078b 100644 --- a/test/beast/core/Jamfile +++ b/test/beast/core/Jamfile @@ -36,9 +36,9 @@ local SOURCES = string_param.cpp type_traits.cpp detail_read.cpp + detail_tuple.cpp detail/base64.cpp detail/clamp.cpp - detail/lean_tuple.cpp detail/sha1.cpp detail/variant.cpp detail/varint.cpp diff --git a/test/beast/core/detail/lean_tuple.cpp b/test/beast/core/detail_tuple.cpp similarity index 77% rename from test/beast/core/detail/lean_tuple.cpp rename to test/beast/core/detail_tuple.cpp index 95c394e3..b3f6d650 100644 --- a/test/beast/core/detail/lean_tuple.cpp +++ b/test/beast/core/detail_tuple.cpp @@ -8,7 +8,7 @@ // // Test that header file is self-contained. -#include +#include #include @@ -16,7 +16,7 @@ namespace boost { namespace beast { namespace detail { -class lean_tuple_test : public beast::unit_test::suite +class tuple_test : public beast::unit_test::suite { public: void @@ -37,17 +37,17 @@ public: int i_; }; - lean_tuple t{nullptr, 42}; + tuple t{nullptr, 42}; BEAST_EXPECT(detail::get<1>(t) == 42); BEAST_EXPECT(detail::get<0>(t).i_ == 0); - t = lean_tuple{explicit_constructible(42), 43}; + t = tuple{explicit_constructible(42), 43}; BEAST_EXPECT(detail::get<1>(t) == 43); BEAST_EXPECT(detail::get<0>(t).i_ == 42); } }; -BEAST_DEFINE_TESTSUITE(beast,core,lean_tuple); +BEAST_DEFINE_TESTSUITE(beast,core,tuple); } // detail } // beast