File indexing completed on 2025-01-18 09:29:24
0001
0002
0003
0004
0005
0006
0007
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
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
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 }
0068 }
0069 }
0070
0071 #endif