]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/beast/core/buffers_cat.hpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / boost / beast / core / buffers_cat.hpp
1 //
2 // Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com)
3 //
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)
6 //
7 // Official repository: https://github.com/boostorg/beast
8 //
9
10 #ifndef BOOST_BEAST_BUFFERS_CAT_HPP
11 #define BOOST_BEAST_BUFFERS_CAT_HPP
12
13 #include <boost/beast/core/detail/config.hpp>
14 #include <boost/beast/core/detail/type_traits.hpp>
15 #include <tuple>
16
17 namespace boost {
18 namespace beast {
19
20 /** A buffer sequence representing a concatenation of buffer sequences.
21
22 @see @ref buffers_cat
23 */
24 template<class... Buffers>
25 class buffers_cat_view
26 {
27 std::tuple<Buffers...> bn_;
28
29 public:
30 /** The type of buffer returned when dereferencing an iterator.
31
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`.
35 */
36 #if BOOST_BEAST_DOXYGEN
37 using value_type = implementation_defined;
38 #else
39 using value_type = typename
40 detail::common_buffers_type<Buffers...>::type;
41 #endif
42
43 /// The type of iterator used by the concatenated sequence
44 class const_iterator;
45
46 /// Constructor
47 buffers_cat_view(buffers_cat_view&&) = default;
48
49 /// Assignment
50 buffers_cat_view& operator=(buffers_cat_view&&) = default;
51
52 /// Assignment
53 buffers_cat_view& operator=(buffers_cat_view const&) = default;
54
55 /** Constructor
56
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.
60 */
61 explicit
62 buffers_cat_view(Buffers const&... buffers);
63
64 //-----
65
66 /// Required for @b BufferSequence
67 buffers_cat_view(buffers_cat_view const&) = default;
68
69 /// Required for @b BufferSequence
70 const_iterator
71 begin() const;
72
73 /// Required for @b BufferSequence
74 const_iterator
75 end() const;
76 };
77
78 /** Concatenate 2 or more buffer sequences.
79
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
85 referenced memory.
86
87 @param buffers The list of buffer sequences to concatenate.
88
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.
94
95 @see @ref buffers_cat_view
96 */
97 #if BOOST_BEAST_DOXYGEN
98 template<class... BufferSequence>
99 buffers_cat_view<BufferSequence...>
100 buffers_cat(BufferSequence const&... buffers)
101 #else
102 template<class B1, class B2, class... Bn>
103 inline
104 buffers_cat_view<B1, B2, Bn...>
105 buffers_cat(B1 const& b1, B2 const& b2, Bn const&... bn)
106 #endif
107 {
108 static_assert(
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...};
112 }
113
114 } // beast
115 } // boost
116
117 #include <boost/beast/core/impl/buffers_cat.ipp>
118
119 #endif