Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:29:27

0001 //
0002 // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
0003 //
0004 // Distributed under the Boost Software License, Version 1.0. (See accompanying
0005 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0006 //
0007 // Official repository: https://github.com/boostorg/beast
0008 //
0009 
0010 #ifndef BOOST_BEAST_BUFFERS_CAT_HPP
0011 #define BOOST_BEAST_BUFFERS_CAT_HPP
0012 
0013 #include <boost/beast/core/detail/config.hpp>
0014 #include <boost/beast/core/buffer_traits.hpp>
0015 #include <boost/beast/core/detail/tuple.hpp>
0016 #include <boost/beast/core/detail/type_traits.hpp>
0017 
0018 namespace boost {
0019 namespace beast {
0020 
0021 /** A buffer sequence representing a concatenation of buffer sequences.
0022     @see buffers_cat
0023 */
0024 template<class... Buffers>
0025 class buffers_cat_view
0026 {
0027     detail::tuple<Buffers...> bn_;
0028 
0029 public:
0030     /** The type of buffer returned when dereferencing an iterator.
0031         If every buffer sequence in the view is a <em>MutableBufferSequence</em>,
0032         then `value_type` will be `net::mutable_buffer`.
0033         Otherwise, `value_type` will be `net::const_buffer`.
0034     */
0035 #if BOOST_BEAST_DOXYGEN
0036     using value_type = __see_below__;
0037 #else
0038     using value_type = buffers_type<Buffers...>;
0039 #endif
0040 
0041     /// The type of iterator used by the concatenated sequence
0042     class const_iterator;
0043 
0044     /// Copy Constructor
0045     buffers_cat_view(buffers_cat_view const&) = default;
0046 
0047     /// Copy Assignment
0048     buffers_cat_view& operator=(buffers_cat_view const&) = default;
0049 
0050     /** Constructor
0051         @param buffers The list of buffer sequences to concatenate.
0052         Copies of the arguments will be maintained for the lifetime
0053         of the concatenated sequence; however, the ownership of the
0054         memory buffers themselves is not transferred.
0055     */
0056     explicit
0057     buffers_cat_view(Buffers const&... buffers);
0058 
0059     /// Returns an iterator to the first buffer in the sequence
0060     const_iterator
0061     begin() const;
0062 
0063     /// Returns an iterator to one past the last buffer in the sequence
0064     const_iterator
0065     end() const;
0066 };
0067 
0068 /** Concatenate 1 or more buffer sequences.
0069 
0070     This function returns a constant or mutable buffer sequence which,
0071     when iterated, efficiently concatenates the input buffer sequences.
0072     Copies of the arguments passed will be made; however, the returned
0073     object does not take ownership of the underlying memory. The
0074     application is still responsible for managing the lifetime of the
0075     referenced memory.
0076     @param buffers The list of buffer sequences to concatenate.
0077     @return A new buffer sequence that represents the concatenation of
0078     the input buffer sequences. This buffer sequence will be a
0079     <em>MutableBufferSequence</em> if each of the passed buffer sequences is
0080     also a <em>MutableBufferSequence</em>; otherwise the returned buffer
0081     sequence will be a <em>ConstBufferSequence</em>.
0082     @see buffers_cat_view
0083 */
0084 #if BOOST_BEAST_DOXYGEN
0085 template<class... BufferSequence>
0086 buffers_cat_view<BufferSequence...>
0087 buffers_cat(BufferSequence const&... buffers)
0088 #else
0089 template<class B1, class... Bn>
0090 buffers_cat_view<B1, Bn...>
0091 buffers_cat(B1 const& b1, Bn const&... bn)
0092 #endif
0093 {
0094     static_assert(
0095         is_const_buffer_sequence<B1, Bn...>::value,
0096         "BufferSequence type requirements not met");
0097     return buffers_cat_view<B1, Bn...>{b1, bn...};
0098 }
0099 
0100 } // beast
0101 } // boost
0102 
0103 #include <boost/beast/core/impl/buffers_cat.hpp>
0104 
0105 #endif