Line |
Branch |
Exec |
Source |
1 |
|
|
// |
2 |
|
|
// Copyright (c) 2023 Vinnie Falco (vinnie.falco@gmail.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/cppalliance/buffers |
8 |
|
|
// |
9 |
|
|
|
10 |
|
|
#ifndef BOOST_BUFFERS_CONST_BUFFER_SUBSPAN_HPP |
11 |
|
|
#define BOOST_BUFFERS_CONST_BUFFER_SUBSPAN_HPP |
12 |
|
|
|
13 |
|
|
#include <boost/buffers/detail/config.hpp> |
14 |
|
|
#include <boost/buffers/const_buffer.hpp> |
15 |
|
|
|
16 |
|
|
namespace boost { |
17 |
|
|
namespace buffers { |
18 |
|
|
|
19 |
|
|
class const_buffer_span; |
20 |
|
|
|
21 |
|
|
/** Holds a span of buffers that cannot be modified. |
22 |
|
|
|
23 |
|
|
Objects of this type meet the requirements |
24 |
|
|
of <em>ConstBufferSequence</em>. |
25 |
|
|
*/ |
26 |
|
|
class const_buffer_subspan |
27 |
|
|
{ |
28 |
|
|
const_buffer const* p_ = nullptr; |
29 |
|
|
std::size_t n_ = 0; |
30 |
|
|
std::size_t p0_ = 0; |
31 |
|
|
std::size_t p1_ = 0; |
32 |
|
|
|
33 |
|
|
friend class const_buffer_span; |
34 |
|
|
|
35 |
|
|
inline |
36 |
|
|
const_buffer_subspan( |
37 |
|
|
const_buffer const* p, |
38 |
|
|
std::size_t n, |
39 |
|
|
std::size_t p0, |
40 |
|
|
std::size_t p1) noexcept; |
41 |
|
|
|
42 |
|
|
public: |
43 |
|
|
/** The type of buffer. |
44 |
|
|
*/ |
45 |
|
|
using value_type = const_buffer; |
46 |
|
|
|
47 |
|
|
/** The type of iterators returned. |
48 |
|
|
*/ |
49 |
|
|
class const_iterator; |
50 |
|
|
|
51 |
|
|
/** Constructor. |
52 |
|
|
*/ |
53 |
|
|
const_buffer_subspan() = default; |
54 |
|
|
|
55 |
|
|
/** Constructor. |
56 |
|
|
*/ |
57 |
|
|
BOOST_BUFFERS_DECL |
58 |
|
|
const_buffer_subspan( |
59 |
|
|
const_buffer const* p, |
60 |
|
|
std::size_t n) noexcept; |
61 |
|
|
|
62 |
|
|
/** Constructor. |
63 |
|
|
*/ |
64 |
|
|
inline |
65 |
|
|
explicit |
66 |
|
|
const_buffer_subspan( |
67 |
|
|
const_buffer_span const& s) noexcept; |
68 |
|
|
|
69 |
|
|
/** Constructor. |
70 |
|
|
*/ |
71 |
|
|
const_buffer_subspan( |
72 |
|
|
const_buffer_subspan const&) = default; |
73 |
|
|
|
74 |
|
|
/** Assignment. |
75 |
|
|
*/ |
76 |
|
|
const_buffer_subspan& operator=( |
77 |
|
|
const_buffer_subspan const&) = default; |
78 |
|
|
|
79 |
|
|
/** Return an iterator to the beginning. |
80 |
|
|
*/ |
81 |
|
|
inline |
82 |
|
|
const_iterator |
83 |
|
|
begin() const noexcept; |
84 |
|
|
|
85 |
|
|
/** Return an iterator to the end. |
86 |
|
|
*/ |
87 |
|
|
inline |
88 |
|
|
const_iterator |
89 |
|
|
end() const noexcept; |
90 |
|
|
|
91 |
|
|
friend |
92 |
|
|
const_buffer_subspan |
93 |
|
358 |
tag_invoke( |
94 |
|
|
prefix_tag const&, |
95 |
|
|
const_buffer_subspan const& s, |
96 |
|
|
std::size_t n) noexcept |
97 |
|
|
{ |
98 |
|
358 |
return s.prefix_impl(n); |
99 |
|
|
} |
100 |
|
|
|
101 |
|
|
friend |
102 |
|
|
const_buffer_subspan |
103 |
|
358 |
tag_invoke( |
104 |
|
|
suffix_tag const&, |
105 |
|
|
const_buffer_subspan const& s, |
106 |
|
|
std::size_t n) noexcept |
107 |
|
|
{ |
108 |
|
358 |
return s.suffix_impl(n); |
109 |
|
|
} |
110 |
|
|
|
111 |
|
|
private: |
112 |
|
|
BOOST_BUFFERS_DECL |
113 |
|
|
const_buffer_subspan |
114 |
|
|
prefix_impl(std::size_t n) const noexcept; |
115 |
|
|
|
116 |
|
|
BOOST_BUFFERS_DECL |
117 |
|
|
const_buffer_subspan |
118 |
|
|
suffix_impl(std::size_t n) const noexcept; |
119 |
|
|
}; |
120 |
|
|
|
121 |
|
|
} // buffers |
122 |
|
|
} // boost |
123 |
|
|
|
124 |
|
|
#include <boost/buffers/impl/const_buffer_subspan.hpp> |
125 |
|
|
|
126 |
|
|
#endif |
127 |
|
|
|