diff --git a/CHANGELOG.md b/CHANGELOG.md index 870048a0..906f4a54 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ Version 256: * Expand CI matrix using Azure Pipelines * Make chat websocket javascript client more user friendly * `allocator_traits::construct` is used for user-defined types +* Add 1-element specialization for `buffers_cat` -------------------------------------------------------------------------------- diff --git a/include/boost/beast/core/buffers_cat.hpp b/include/boost/beast/core/buffers_cat.hpp index 0f989210..f1373291 100644 --- a/include/boost/beast/core/buffers_cat.hpp +++ b/include/boost/beast/core/buffers_cat.hpp @@ -65,7 +65,8 @@ public: end() const; }; -/** Concatenate 2 or more buffer sequences. +/** Concatenate 1 or more buffer sequences. + This function returns a constant or mutable buffer sequence which, when iterated, efficiently concatenates the input buffer sequences. Copies of the arguments passed will be made; however, the returned @@ -85,15 +86,15 @@ template buffers_cat_view buffers_cat(BufferSequence const&... buffers) #else -template -buffers_cat_view -buffers_cat(B1 const& b1, B2 const& b2, Bn const&... bn) +template +buffers_cat_view +buffers_cat(B1 const& b1, Bn const&... bn) #endif { static_assert( - is_const_buffer_sequence::value, + is_const_buffer_sequence::value, "BufferSequence type requirements not met"); - return buffers_cat_view{b1, b2, bn...}; + return buffers_cat_view{b1, bn...}; } } // beast diff --git a/include/boost/beast/core/impl/buffers_cat.hpp b/include/boost/beast/core/impl/buffers_cat.hpp index 255153f2..81a6c78d 100644 --- a/include/boost/beast/core/impl/buffers_cat.hpp +++ b/include/boost/beast/core/impl/buffers_cat.hpp @@ -23,6 +23,34 @@ namespace boost { namespace beast { +template +class buffers_cat_view +{ + Buffer buffer_; +public: + using value_type = buffers_type; + + using const_iterator = buffers_iterator_type; + + explicit + buffers_cat_view(Buffer const& buffer) + : buffer_(buffer) + { + } + + const_iterator + begin() const + { + return net::buffer_sequence_begin(buffer_); + } + + const_iterator + end() const + { + return net::buffer_sequence_end(buffer_); + } +}; + #if defined(_MSC_VER) && ! defined(__clang__) # define BOOST_BEAST_UNREACHABLE() __assume(false) # define BOOST_BEAST_UNREACHABLE_RETURN(v) __assume(false)