GCC Code Coverage Report


Directory: libs/buffers/
File: boost/buffers/mutable_buffer_subspan.hpp
Date: 2024-07-24 21:34:17
Exec Total Coverage
Lines: 4 4 100.0%
Functions: 2 2 100.0%
Branches: 0 0 -%

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_MUTABLE_BUFFER_SUBSPAN_HPP
11 #define BOOST_BUFFERS_MUTABLE_BUFFER_SUBSPAN_HPP
12
13 #include <boost/buffers/detail/config.hpp>
14 #include <boost/buffers/mutable_buffer.hpp>
15
16 namespace boost {
17 namespace buffers {
18
19 class mutable_buffer_span;
20
21 /** Holds a span of buffers whose contents are modifiable.
22
23 Objects of this type meet the requirements
24 of <em>MutableBufferSequence</em>.
25 */
26 class mutable_buffer_subspan
27 {
28 mutable_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 mutable_buffer_span;
34
35 inline
36 mutable_buffer_subspan(
37 mutable_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 = mutable_buffer;
46
47 /** The type of iterators returned.
48 */
49 class const_iterator;
50
51 /** Constructor.
52 */
53 mutable_buffer_subspan() = default;
54
55 /** Constructor.
56 */
57 BOOST_BUFFERS_DECL
58 mutable_buffer_subspan(
59 mutable_buffer const* p,
60 std::size_t n) noexcept;
61
62 /** Constructor.
63 */
64 inline
65 explicit
66 mutable_buffer_subspan(
67 mutable_buffer_span const& s) noexcept;
68
69 /** Constructor.
70 */
71 mutable_buffer_subspan(
72 mutable_buffer_subspan const&) = default;
73
74 /** Assignment.
75 */
76 mutable_buffer_subspan& operator=(
77 mutable_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 mutable_buffer_subspan
93 358 tag_invoke(
94 prefix_tag const&,
95 mutable_buffer_subspan const& s,
96 std::size_t n) noexcept
97 {
98 358 return s.prefix_impl(n);
99 }
100
101 friend
102 mutable_buffer_subspan
103 358 tag_invoke(
104 suffix_tag const&,
105 mutable_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 mutable_buffer_subspan
114 prefix_impl(std::size_t n) const noexcept;
115
116 BOOST_BUFFERS_DECL
117 mutable_buffer_subspan
118 suffix_impl(std::size_t n) const noexcept;
119 };
120
121 } // buffers
122 } // boost
123
124 #include <boost/buffers/impl/mutable_buffer_subspan.hpp>
125
126 #endif
127