2 // Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com)
4 // Distributed under the Boost Software License, Version 1.0. (See accompanying
5 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 // Official repository: https://github.com/boostorg/beast
10 #ifndef BOOST_BEAST_BUFFERS_CAT_HPP
11 #define BOOST_BEAST_BUFFERS_CAT_HPP
13 #include <boost/beast/core/detail/config.hpp>
14 #include <boost/beast/core/detail/type_traits.hpp>
20 /** A buffer sequence representing a concatenation of buffer sequences.
24 template<class... Buffers>
25 class buffers_cat_view
27 std::tuple<Buffers...> bn_;
30 /** The type of buffer returned when dereferencing an iterator.
32 If every buffer sequence in the view is a @b MutableBufferSequence,
33 then `value_type` will be `boost::asio::mutable_buffer`.
34 Otherwise, `value_type` will be `boost::asio::const_buffer`.
36 #if BOOST_BEAST_DOXYGEN
37 using value_type = implementation_defined;
39 using value_type = typename
40 detail::common_buffers_type<Buffers...>::type;
43 /// The type of iterator used by the concatenated sequence
47 buffers_cat_view(buffers_cat_view&&) = default;
50 buffers_cat_view& operator=(buffers_cat_view&&) = default;
53 buffers_cat_view& operator=(buffers_cat_view const&) = default;
57 @param buffers The list of buffer sequences to concatenate.
58 Copies of the arguments will be made; however, the ownership
59 of memory is not transferred.
62 buffers_cat_view(Buffers const&... buffers);
66 /// Required for @b BufferSequence
67 buffers_cat_view(buffers_cat_view const&) = default;
69 /// Required for @b BufferSequence
73 /// Required for @b BufferSequence
78 /** Concatenate 2 or more buffer sequences.
80 This function returns a constant or mutable buffer sequence which,
81 when iterated, efficiently concatenates the input buffer sequences.
82 Copies of the arguments passed will be made; however, the returned
83 object does not take ownership of the underlying memory. The
84 application is still responsible for managing the lifetime of the
87 @param buffers The list of buffer sequences to concatenate.
89 @return A new buffer sequence that represents the concatenation of
90 the input buffer sequences. This buffer sequence will be a
91 @b MutableBufferSequence if each of the passed buffer sequences is
92 also a @b MutableBufferSequence; otherwise the returned buffer
93 sequence will be a @b ConstBufferSequence.
95 @see @ref buffers_cat_view
97 #if BOOST_BEAST_DOXYGEN
98 template<class... BufferSequence>
99 buffers_cat_view<BufferSequence...>
100 buffers_cat(BufferSequence const&... buffers)
102 template<class B1, class B2, class... Bn>
104 buffers_cat_view<B1, B2, Bn...>
105 buffers_cat(B1 const& b1, B2 const& b2, Bn const&... bn)
109 detail::is_all_const_buffer_sequence<B1, B2, Bn...>::value,
110 "BufferSequence requirements not met");
111 return buffers_cat_view<B1, B2, Bn...>{b1, b2, bn...};
117 #include <boost/beast/core/impl/buffers_cat.ipp>