Back to home page

EIC code displayed by LXR

 
 

    


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

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_DETAIL_BUFFERS_REF_HPP
0011 #define BOOST_BEAST_DETAIL_BUFFERS_REF_HPP
0012 
0013 #include <boost/beast/core/buffer_traits.hpp>
0014 #include <iterator>
0015 #include <memory>
0016 
0017 namespace boost {
0018 namespace beast {
0019 namespace detail {
0020 
0021 // A very lightweight reference to a buffer sequence
0022 template<class BufferSequence>
0023 class buffers_ref
0024 {
0025     BufferSequence const* buffers_;
0026 
0027 public:
0028     using const_iterator =
0029         buffers_iterator_type<BufferSequence>;
0030 
0031     using value_type = typename
0032         std::iterator_traits<const_iterator>::value_type;
0033 
0034     buffers_ref(buffers_ref const&) = default;
0035     buffers_ref& operator=(buffers_ref const&) = default;
0036 
0037     explicit
0038     buffers_ref(BufferSequence const& buffers)
0039         : buffers_(std::addressof(buffers))
0040     {
0041     }
0042 
0043     const_iterator
0044     begin() const
0045     {
0046         return net::buffer_sequence_begin(*buffers_);
0047     }
0048 
0049     const_iterator
0050     end() const
0051     {
0052         return net::buffer_sequence_end(*buffers_);
0053     }
0054 };
0055 
0056 // Return a reference to a buffer sequence
0057 template<class BufferSequence>
0058 buffers_ref<BufferSequence>
0059 make_buffers_ref(BufferSequence const& buffers)
0060 {
0061     static_assert(
0062         is_const_buffer_sequence<BufferSequence>::value,
0063         "BufferSequence type requirements not met");
0064     return buffers_ref<BufferSequence>(buffers);
0065 }
0066 
0067 } // detail
0068 } // beast
0069 } // boost
0070 
0071 #endif