]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/beast/core/detail/buffers_ref.hpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / boost / beast / core / detail / buffers_ref.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_DETAIL_BUFFERS_REF_HPP
11 #define BOOST_BEAST_DETAIL_BUFFERS_REF_HPP
12
13 #include <boost/beast/core/type_traits.hpp>
14 #include <iterator>
15
16 namespace boost {
17 namespace beast {
18 namespace detail {
19
20 // A very lightweight reference to a buffer sequence
21 template<class BufferSequence>
22 class buffers_ref
23 {
24 BufferSequence const* buffers_;
25
26 public:
27 using const_iterator = typename
28 buffer_sequence_iterator<BufferSequence>::type;
29
30 using value_type = typename std::iterator_traits<
31 const_iterator>::value_type;
32
33 buffers_ref(buffers_ref const&) = default;
34 buffers_ref& operator=(buffers_ref const&) = default;
35
36 explicit
37 buffers_ref(BufferSequence const& buffers)
38 : buffers_(std::addressof(buffers))
39 {
40 }
41
42 const_iterator
43 begin() const
44 {
45 return boost::asio::buffer_sequence_begin(*buffers_);
46 }
47
48 const_iterator
49 end() const
50 {
51 return boost::asio::buffer_sequence_end(*buffers_);
52 }
53 };
54
55 // Return a reference to a buffer sequence
56 template<class BufferSequence>
57 buffers_ref<BufferSequence>
58 make_buffers_ref(BufferSequence const& buffers)
59 {
60 return buffers_ref<BufferSequence>(buffers);
61 }
62
63 } // detail
64 } // beast
65 } // boost
66
67 #endif