include/boost/capy/detail/slice_of.hpp
100.0% Lines (72/72)
97.3% List of functions (109/112)
Functions (112)
Function
Calls
Lines
Blocks
boost::capy::detail::slice_of<boost::capy::const_buffer>::adjust(boost::capy::const_buffer const&, unsigned long, unsigned long)
:62
222x
100.0%
100.0%
boost::capy::detail::slice_of<boost::capy::detail::buffer_array<4ul, false> >::adjust(boost::capy::mutable_buffer const&, unsigned long, unsigned long)
:62
15840x
100.0%
100.0%
boost::capy::detail::slice_of<boost::capy::detail::buffer_array<4ul, true> >::adjust(boost::capy::const_buffer const&, unsigned long, unsigned long)
:62
15840x
100.0%
100.0%
boost::capy::detail::slice_of<boost::capy::mutable_buffer>::adjust(boost::capy::mutable_buffer const&, unsigned long, unsigned long)
:62
195x
100.0%
100.0%
boost::capy::detail::slice_of<std::array<boost::capy::const_buffer, 2ul> >::adjust(boost::capy::const_buffer const&, unsigned long, unsigned long)
:62
138x
100.0%
100.0%
boost::capy::detail::slice_of<std::array<boost::capy::const_buffer, 3ul> >::adjust(boost::capy::const_buffer const&, unsigned long, unsigned long)
:62
48x
100.0%
100.0%
boost::capy::detail::slice_of<std::array<boost::capy::mutable_buffer, 1ul> >::adjust(boost::capy::mutable_buffer const&, unsigned long, unsigned long)
:62
3x
100.0%
100.0%
boost::capy::detail::slice_of<std::array<boost::capy::mutable_buffer, 2ul> >::adjust(boost::capy::mutable_buffer const&, unsigned long, unsigned long)
:62
108x
100.0%
100.0%
boost::capy::detail::slice_of<std::array<boost::capy::mutable_buffer, 3ul> >::adjust(boost::capy::mutable_buffer const&, unsigned long, unsigned long)
:62
2x
100.0%
100.0%
boost::capy::detail::slice_of<std::span<boost::capy::const_buffer const, 18446744073709551615ul> >::adjust(boost::capy::const_buffer const&, unsigned long, unsigned long)
:62
858x
100.0%
100.0%
boost::capy::detail::slice_of<std::span<boost::capy::mutable_buffer const, 18446744073709551615ul> >::adjust(boost::capy::mutable_buffer const&, unsigned long, unsigned long)
:62
858x
100.0%
100.0%
boost::capy::detail::slice_of<boost::capy::const_buffer>::const_iterator::const_iterator(boost::capy::const_buffer const*, boost::capy::const_buffer const*, boost::capy::const_buffer const*, unsigned long, unsigned long)
:94
444x
100.0%
100.0%
boost::capy::detail::slice_of<boost::capy::detail::buffer_array<4ul, false> >::const_iterator::const_iterator(boost::capy::mutable_buffer const*, boost::capy::mutable_buffer const*, boost::capy::mutable_buffer const*, unsigned long, unsigned long)
:94
23936x
100.0%
100.0%
boost::capy::detail::slice_of<boost::capy::detail::buffer_array<4ul, true> >::const_iterator::const_iterator(boost::capy::const_buffer const*, boost::capy::const_buffer const*, boost::capy::const_buffer const*, unsigned long, unsigned long)
:94
23936x
100.0%
100.0%
boost::capy::detail::slice_of<boost::capy::mutable_buffer>::const_iterator::const_iterator(boost::capy::mutable_buffer const*, boost::capy::mutable_buffer const*, boost::capy::mutable_buffer const*, unsigned long, unsigned long)
:94
390x
100.0%
100.0%
boost::capy::detail::slice_of<std::array<boost::capy::const_buffer, 2ul> >::const_iterator::const_iterator(boost::capy::const_buffer const*, boost::capy::const_buffer const*, boost::capy::const_buffer const*, unsigned long, unsigned long)
:94
180x
100.0%
100.0%
boost::capy::detail::slice_of<std::array<boost::capy::const_buffer, 3ul> >::const_iterator::const_iterator(boost::capy::const_buffer const*, boost::capy::const_buffer const*, boost::capy::const_buffer const*, unsigned long, unsigned long)
:94
56x
100.0%
100.0%
boost::capy::detail::slice_of<std::array<boost::capy::mutable_buffer, 1ul> >::const_iterator::const_iterator(boost::capy::mutable_buffer const*, boost::capy::mutable_buffer const*, boost::capy::mutable_buffer const*, unsigned long, unsigned long)
:94
15x
100.0%
100.0%
boost::capy::detail::slice_of<std::array<boost::capy::mutable_buffer, 2ul> >::const_iterator::const_iterator(boost::capy::mutable_buffer const*, boost::capy::mutable_buffer const*, boost::capy::mutable_buffer const*, unsigned long, unsigned long)
:94
190x
100.0%
100.0%
boost::capy::detail::slice_of<std::array<boost::capy::mutable_buffer, 3ul> >::const_iterator::const_iterator(boost::capy::mutable_buffer const*, boost::capy::mutable_buffer const*, boost::capy::mutable_buffer const*, unsigned long, unsigned long)
:94
5x
100.0%
100.0%
boost::capy::detail::slice_of<std::span<boost::capy::const_buffer const, 18446744073709551615ul> >::const_iterator::const_iterator(__gnu_cxx::__normal_iterator<boost::capy::const_buffer const*, std::span<boost::capy::const_buffer const, 18446744073709551615ul> >, __gnu_cxx::__normal_iterator<boost::capy::const_buffer const*, std::span<boost::capy::const_buffer const, 18446744073709551615ul> >, __gnu_cxx::__normal_iterator<boost::capy::const_buffer const*, std::span<boost::capy::const_buffer const, 18446744073709551615ul> >, unsigned long, unsigned long)
:94
968x
100.0%
100.0%
boost::capy::detail::slice_of<std::span<boost::capy::mutable_buffer const, 18446744073709551615ul> >::const_iterator::const_iterator(__gnu_cxx::__normal_iterator<boost::capy::mutable_buffer const*, std::span<boost::capy::mutable_buffer const, 18446744073709551615ul> >, __gnu_cxx::__normal_iterator<boost::capy::mutable_buffer const*, std::span<boost::capy::mutable_buffer const, 18446744073709551615ul> >, __gnu_cxx::__normal_iterator<boost::capy::mutable_buffer const*, std::span<boost::capy::mutable_buffer const, 18446744073709551615ul> >, unsigned long, unsigned long)
:94
968x
100.0%
100.0%
boost::capy::detail::slice_of<boost::capy::const_buffer>::const_iterator::operator==(boost::capy::detail::slice_of<boost::capy::const_buffer>::const_iterator const&) const
:106
280x
100.0%
100.0%
boost::capy::detail::slice_of<boost::capy::detail::buffer_array<4ul, false> >::const_iterator::operator==(boost::capy::detail::slice_of<boost::capy::detail::buffer_array<4ul, false> >::const_iterator const&) const
:106
27808x
100.0%
100.0%
boost::capy::detail::slice_of<boost::capy::detail::buffer_array<4ul, true> >::const_iterator::operator==(boost::capy::detail::slice_of<boost::capy::detail::buffer_array<4ul, true> >::const_iterator const&) const
:106
27808x
100.0%
100.0%
boost::capy::detail::slice_of<boost::capy::mutable_buffer>::const_iterator::operator==(boost::capy::detail::slice_of<boost::capy::mutable_buffer>::const_iterator const&) const
:106
207x
100.0%
100.0%
boost::capy::detail::slice_of<std::array<boost::capy::const_buffer, 2ul> >::const_iterator::operator==(boost::capy::detail::slice_of<std::array<boost::capy::const_buffer, 2ul> >::const_iterator const&) const
:106
156x
100.0%
100.0%
boost::capy::detail::slice_of<std::array<boost::capy::const_buffer, 3ul> >::const_iterator::operator==(boost::capy::detail::slice_of<std::array<boost::capy::const_buffer, 3ul> >::const_iterator const&) const
:106
76x
100.0%
100.0%
boost::capy::detail::slice_of<std::array<boost::capy::mutable_buffer, 1ul> >::const_iterator::operator==(boost::capy::detail::slice_of<std::array<boost::capy::mutable_buffer, 1ul> >::const_iterator const&) const
:106
10x
100.0%
100.0%
boost::capy::detail::slice_of<std::array<boost::capy::mutable_buffer, 2ul> >::const_iterator::operator==(boost::capy::detail::slice_of<std::array<boost::capy::mutable_buffer, 2ul> >::const_iterator const&) const
:106
130x
100.0%
100.0%
boost::capy::detail::slice_of<std::array<boost::capy::mutable_buffer, 3ul> >::const_iterator::operator==(boost::capy::detail::slice_of<std::array<boost::capy::mutable_buffer, 3ul> >::const_iterator const&) const
:106
4x
100.0%
100.0%
boost::capy::detail::slice_of<std::span<boost::capy::const_buffer const, 18446744073709551615ul> >::const_iterator::operator==(boost::capy::detail::slice_of<std::span<boost::capy::const_buffer const, 18446744073709551615ul> >::const_iterator const&) const
:106
1342x
100.0%
100.0%
boost::capy::detail::slice_of<std::span<boost::capy::mutable_buffer const, 18446744073709551615ul> >::const_iterator::operator==(boost::capy::detail::slice_of<std::span<boost::capy::mutable_buffer const, 18446744073709551615ul> >::const_iterator const&) const
:106
1342x
100.0%
100.0%
boost::capy::detail::slice_of<boost::capy::const_buffer>::const_iterator::operator!=(boost::capy::detail::slice_of<boost::capy::const_buffer>::const_iterator const&) const
:111
280x
100.0%
100.0%
boost::capy::detail::slice_of<boost::capy::detail::buffer_array<4ul, false> >::const_iterator::operator!=(boost::capy::detail::slice_of<boost::capy::detail::buffer_array<4ul, false> >::const_iterator const&) const
:111
27808x
100.0%
100.0%
boost::capy::detail::slice_of<boost::capy::detail::buffer_array<4ul, true> >::const_iterator::operator!=(boost::capy::detail::slice_of<boost::capy::detail::buffer_array<4ul, true> >::const_iterator const&) const
:111
27808x
100.0%
100.0%
boost::capy::detail::slice_of<boost::capy::mutable_buffer>::const_iterator::operator!=(boost::capy::detail::slice_of<boost::capy::mutable_buffer>::const_iterator const&) const
:111
207x
100.0%
100.0%
boost::capy::detail::slice_of<std::array<boost::capy::const_buffer, 2ul> >::const_iterator::operator!=(boost::capy::detail::slice_of<std::array<boost::capy::const_buffer, 2ul> >::const_iterator const&) const
:111
156x
100.0%
100.0%
boost::capy::detail::slice_of<std::array<boost::capy::const_buffer, 3ul> >::const_iterator::operator!=(boost::capy::detail::slice_of<std::array<boost::capy::const_buffer, 3ul> >::const_iterator const&) const
:111
76x
100.0%
100.0%
boost::capy::detail::slice_of<std::array<boost::capy::mutable_buffer, 1ul> >::const_iterator::operator!=(boost::capy::detail::slice_of<std::array<boost::capy::mutable_buffer, 1ul> >::const_iterator const&) const
:111
10x
100.0%
100.0%
boost::capy::detail::slice_of<std::array<boost::capy::mutable_buffer, 2ul> >::const_iterator::operator!=(boost::capy::detail::slice_of<std::array<boost::capy::mutable_buffer, 2ul> >::const_iterator const&) const
:111
130x
100.0%
100.0%
boost::capy::detail::slice_of<std::array<boost::capy::mutable_buffer, 3ul> >::const_iterator::operator!=(boost::capy::detail::slice_of<std::array<boost::capy::mutable_buffer, 3ul> >::const_iterator const&) const
:111
4x
100.0%
100.0%
boost::capy::detail::slice_of<std::span<boost::capy::const_buffer const, 18446744073709551615ul> >::const_iterator::operator!=(boost::capy::detail::slice_of<std::span<boost::capy::const_buffer const, 18446744073709551615ul> >::const_iterator const&) const
:111
1342x
100.0%
100.0%
boost::capy::detail::slice_of<std::span<boost::capy::mutable_buffer const, 18446744073709551615ul> >::const_iterator::operator!=(boost::capy::detail::slice_of<std::span<boost::capy::mutable_buffer const, 18446744073709551615ul> >::const_iterator const&) const
:111
1342x
100.0%
100.0%
boost::capy::detail::slice_of<boost::capy::const_buffer>::const_iterator::operator*() const
:116
222x
100.0%
78.0%
boost::capy::detail::slice_of<boost::capy::detail::buffer_array<4ul, false> >::const_iterator::operator*() const
:116
15840x
100.0%
100.0%
boost::capy::detail::slice_of<boost::capy::detail::buffer_array<4ul, true> >::const_iterator::operator*() const
:116
15840x
100.0%
100.0%
boost::capy::detail::slice_of<boost::capy::mutable_buffer>::const_iterator::operator*() const
:116
195x
100.0%
78.0%
boost::capy::detail::slice_of<std::array<boost::capy::const_buffer, 2ul> >::const_iterator::operator*() const
:116
138x
100.0%
100.0%
boost::capy::detail::slice_of<std::array<boost::capy::const_buffer, 3ul> >::const_iterator::operator*() const
:116
48x
100.0%
100.0%
boost::capy::detail::slice_of<std::array<boost::capy::mutable_buffer, 1ul> >::const_iterator::operator*() const
:116
3x
100.0%
78.0%
boost::capy::detail::slice_of<std::array<boost::capy::mutable_buffer, 2ul> >::const_iterator::operator*() const
:116
108x
100.0%
100.0%
boost::capy::detail::slice_of<std::array<boost::capy::mutable_buffer, 3ul> >::const_iterator::operator*() const
:116
2x
100.0%
78.0%
boost::capy::detail::slice_of<std::span<boost::capy::const_buffer const, 18446744073709551615ul> >::const_iterator::operator*() const
:116
858x
100.0%
100.0%
boost::capy::detail::slice_of<std::span<boost::capy::mutable_buffer const, 18446744073709551615ul> >::const_iterator::operator*() const
:116
858x
100.0%
100.0%
boost::capy::detail::slice_of<boost::capy::const_buffer>::const_iterator::operator++()
:126
192x
100.0%
100.0%
boost::capy::detail::slice_of<boost::capy::detail::buffer_array<4ul, false> >::const_iterator::operator++()
:126
10080x
100.0%
100.0%
boost::capy::detail::slice_of<boost::capy::detail::buffer_array<4ul, true> >::const_iterator::operator++()
:126
10080x
100.0%
100.0%
boost::capy::detail::slice_of<boost::capy::mutable_buffer>::const_iterator::operator++()
:126
176x
100.0%
100.0%
boost::capy::detail::slice_of<std::array<boost::capy::const_buffer, 2ul> >::const_iterator::operator++()
:126
138x
100.0%
100.0%
boost::capy::detail::slice_of<std::array<boost::capy::const_buffer, 3ul> >::const_iterator::operator++()
:126
48x
100.0%
100.0%
boost::capy::detail::slice_of<std::array<boost::capy::mutable_buffer, 1ul> >::const_iterator::operator++()
:126
3x
100.0%
100.0%
boost::capy::detail::slice_of<std::array<boost::capy::mutable_buffer, 2ul> >::const_iterator::operator++()
:126
100x
100.0%
100.0%
boost::capy::detail::slice_of<std::array<boost::capy::mutable_buffer, 3ul> >::const_iterator::operator++()
:126
2x
100.0%
100.0%
boost::capy::detail::slice_of<std::span<boost::capy::const_buffer const, 18446744073709551615ul> >::const_iterator::operator++()
:126
546x
100.0%
100.0%
boost::capy::detail::slice_of<std::span<boost::capy::mutable_buffer const, 18446744073709551615ul> >::const_iterator::operator++()
:126
546x
100.0%
100.0%
boost::capy::detail::slice_of<boost::capy::const_buffer>::const_iterator::operator++(int)
:127
110x
100.0%
100.0%
boost::capy::detail::slice_of<boost::capy::detail::buffer_array<4ul, false> >::const_iterator::operator++(int)
:127
2880x
100.0%
100.0%
boost::capy::detail::slice_of<boost::capy::detail::buffer_array<4ul, true> >::const_iterator::operator++(int)
:127
2880x
100.0%
100.0%
boost::capy::detail::slice_of<boost::capy::mutable_buffer>::const_iterator::operator++(int)
:127
140x
100.0%
100.0%
boost::capy::detail::slice_of<std::array<boost::capy::const_buffer, 2ul> >::const_iterator::operator++(int)
:127
66x
100.0%
100.0%
boost::capy::detail::slice_of<std::array<boost::capy::mutable_buffer, 1ul> >::const_iterator::operator++(int)
:127
0
50.0%
0.0%
boost::capy::detail::slice_of<std::array<boost::capy::mutable_buffer, 2ul> >::const_iterator::operator++(int)
:127
48x
100.0%
100.0%
boost::capy::detail::slice_of<std::span<boost::capy::const_buffer const, 18446744073709551615ul> >::const_iterator::operator++(int)
:127
156x
100.0%
100.0%
boost::capy::detail::slice_of<std::span<boost::capy::mutable_buffer const, 18446744073709551615ul> >::const_iterator::operator++(int)
:127
156x
100.0%
100.0%
boost::capy::detail::slice_of<boost::capy::detail::buffer_array<4ul, false> >::const_iterator::operator--()
:129
5760x
100.0%
100.0%
boost::capy::detail::slice_of<boost::capy::detail::buffer_array<4ul, true> >::const_iterator::operator--()
:129
5760x
100.0%
100.0%
boost::capy::detail::slice_of<std::span<boost::capy::const_buffer const, 18446744073709551615ul> >::const_iterator::operator--()
:129
312x
100.0%
100.0%
boost::capy::detail::slice_of<std::span<boost::capy::mutable_buffer const, 18446744073709551615ul> >::const_iterator::operator--()
:129
312x
100.0%
100.0%
boost::capy::detail::slice_of<boost::capy::detail::buffer_array<4ul, false> >::const_iterator::operator--(int)
:130
2880x
100.0%
100.0%
boost::capy::detail::slice_of<boost::capy::detail::buffer_array<4ul, true> >::const_iterator::operator--(int)
:130
2880x
100.0%
100.0%
boost::capy::detail::slice_of<std::span<boost::capy::const_buffer const, 18446744073709551615ul> >::const_iterator::operator--(int)
:130
156x
100.0%
100.0%
boost::capy::detail::slice_of<std::span<boost::capy::mutable_buffer const, 18446744073709551615ul> >::const_iterator::operator--(int)
:130
156x
100.0%
100.0%
boost::capy::detail::slice_of<boost::capy::detail::buffer_array<4ul, false> >::slice_of(boost::capy::detail::buffer_array<4ul, false> const&, unsigned long, unsigned long)
:143
1088x
100.0%
100.0%
boost::capy::detail::slice_of<boost::capy::detail::buffer_array<4ul, true> >::slice_of(boost::capy::detail::buffer_array<4ul, true> const&, unsigned long, unsigned long)
:143
1088x
100.0%
100.0%
boost::capy::detail::slice_of<std::array<boost::capy::const_buffer, 1ul> >::slice_of(std::array<boost::capy::const_buffer, 1ul> const&, unsigned long, unsigned long)
:143
1x
41.9%
55.0%
boost::capy::detail::slice_of<std::array<boost::capy::const_buffer, 3ul> >::slice_of(std::array<boost::capy::const_buffer, 3ul> const&, unsigned long, unsigned long)
:143
14x
100.0%
100.0%
boost::capy::detail::slice_of<std::array<boost::capy::mutable_buffer, 1ul> >::slice_of(std::array<boost::capy::mutable_buffer, 1ul> const&, unsigned long, unsigned long)
:143
4x
83.9%
91.0%
boost::capy::detail::slice_of<std::array<boost::capy::mutable_buffer, 2ul> >::slice_of(std::array<boost::capy::mutable_buffer, 2ul> const&, unsigned long, unsigned long)
:143
7x
93.5%
91.0%
boost::capy::detail::slice_of<std::array<boost::capy::mutable_buffer, 3ul> >::slice_of(std::array<boost::capy::mutable_buffer, 3ul> const&, unsigned long, unsigned long)
:143
1x
48.4%
59.0%
boost::capy::detail::slice_of<std::span<boost::capy::const_buffer const, 18446744073709551615ul> >::slice_of(std::span<boost::capy::const_buffer const, 18446744073709551615ul> const&, unsigned long, unsigned long)
:143
44x
100.0%
100.0%
boost::capy::detail::slice_of<std::span<boost::capy::mutable_buffer const, 18446744073709551615ul> >::slice_of(std::span<boost::capy::mutable_buffer const, 18446744073709551615ul> const&, unsigned long, unsigned long)
:143
44x
100.0%
100.0%
boost::capy::detail::slice_of<boost::capy::const_buffer>::slice_of(boost::capy::const_buffer const*, boost::capy::const_buffer const*, unsigned long, unsigned long)
:198
115x
100.0%
100.0%
boost::capy::detail::slice_of<boost::capy::mutable_buffer>::slice_of(boost::capy::mutable_buffer const*, boost::capy::mutable_buffer const*, unsigned long, unsigned long)
:198
108x
100.0%
100.0%
boost::capy::detail::slice_of<std::array<boost::capy::const_buffer, 1ul> >::slice_of(boost::capy::const_buffer const*, boost::capy::const_buffer const*, unsigned long, unsigned long)
:198
0
0.0%
0.0%
boost::capy::detail::slice_of<std::array<boost::capy::const_buffer, 256ul> >::slice_of(boost::capy::const_buffer const*, boost::capy::const_buffer const*, unsigned long, unsigned long)
:198
0
0.0%
0.0%
boost::capy::detail::slice_of<std::array<boost::capy::const_buffer, 2ul> >::slice_of(boost::capy::const_buffer const*, boost::capy::const_buffer const*, unsigned long, unsigned long)
:198
54x
100.0%
100.0%
boost::capy::detail::slice_of<std::array<boost::capy::mutable_buffer, 1ul> >::slice_of(boost::capy::mutable_buffer const*, boost::capy::mutable_buffer const*, unsigned long, unsigned long)
:198
2x
100.0%
100.0%
boost::capy::detail::slice_of<std::array<boost::capy::mutable_buffer, 2ul> >::slice_of(boost::capy::mutable_buffer const*, boost::capy::mutable_buffer const*, unsigned long, unsigned long)
:198
56x
100.0%
100.0%
boost::capy::detail::slice_of<boost::capy::const_buffer>::begin() const
:209
222x
100.0%
100.0%
boost::capy::detail::slice_of<boost::capy::detail::buffer_array<4ul, false> >::begin() const
:209
11968x
100.0%
100.0%
boost::capy::detail::slice_of<boost::capy::detail::buffer_array<4ul, true> >::begin() const
:209
11968x
100.0%
100.0%
boost::capy::detail::slice_of<boost::capy::mutable_buffer>::begin() const
:209
195x
100.0%
100.0%
boost::capy::detail::slice_of<std::array<boost::capy::const_buffer, 2ul> >::begin() const
:209
90x
100.0%
100.0%
boost::capy::detail::slice_of<std::array<boost::capy::const_buffer, 3ul> >::begin() const
:209
28x
100.0%
100.0%
boost::capy::detail::slice_of<std::array<boost::capy::mutable_buffer, 1ul> >::begin() const
:209
7x
100.0%
100.0%
boost::capy::detail::slice_of<std::array<boost::capy::mutable_buffer, 2ul> >::begin() const
:209
86x
100.0%
100.0%
boost::capy::detail::slice_of<std::array<boost::capy::mutable_buffer, 3ul> >::begin() const
:209
2x
100.0%
100.0%
boost::capy::detail::slice_of<std::span<boost::capy::const_buffer const, 18446744073709551615ul> >::begin() const
:209
484x
100.0%
100.0%
boost::capy::detail::slice_of<std::span<boost::capy::mutable_buffer const, 18446744073709551615ul> >::begin() const
:209
484x
100.0%
100.0%
boost::capy::detail::slice_of<boost::capy::mutable_buffer>::end() const
:216
96x
100.0%
100.0%
boost::capy::detail::slice_of<std::array<boost::capy::const_buffer, 3ul> >::end() const
:216
28x
100.0%
100.0%
| Line | TLA | Hits | Source Code |
|---|---|---|---|
| 1 | // | ||
| 2 | // Copyright (c) 2026 Steve Gerbino | ||
| 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/capy | ||
| 8 | // | ||
| 9 | |||
| 10 | #ifndef BOOST_CAPY_DETAIL_SLICE_OF_HPP | ||
| 11 | #define BOOST_CAPY_DETAIL_SLICE_OF_HPP | ||
| 12 | |||
| 13 | #include <boost/capy/detail/config.hpp> | ||
| 14 | #include <boost/capy/buffers.hpp> | ||
| 15 | |||
| 16 | #include <cstddef> | ||
| 17 | #include <iterator> | ||
| 18 | #include <limits> | ||
| 19 | #include <type_traits> | ||
| 20 | |||
| 21 | namespace boost { | ||
| 22 | namespace capy { | ||
| 23 | namespace detail { | ||
| 24 | |||
| 25 | /** A borrowed view over a byte sub-range of a buffer sequence. | ||
| 26 | |||
| 27 | `slice_of<BS>` is the generic result of `buffer_slice` for a sequence | ||
| 28 | that is not closed under sub-ranging (everything except a single | ||
| 29 | buffer). It models the same buffer-sequence concept as `BS` | ||
| 30 | (`MutableBufferSequence` if `BS` is mutable, otherwise | ||
| 31 | `ConstBufferSequence`), so it can be passed anywhere a buffer sequence | ||
| 32 | is expected. | ||
| 33 | |||
| 34 | It stores iterators into the underlying sequence plus front/back byte | ||
| 35 | offsets; it neither owns nor copies the descriptors. The underlying | ||
| 36 | sequence must outlive the view. | ||
| 37 | |||
| 38 | @par Complexity | ||
| 39 | Construction is a single forward pass to the cut points: O(buffers up | ||
| 40 | to `offset`) for a to-end slice, O(buffers up to `offset + length`) | ||
| 41 | for a bounded slice. It never sums the whole sequence. | ||
| 42 | */ | ||
| 43 | template<class BS> | ||
| 44 | requires MutableBufferSequence<BS> || ConstBufferSequence<BS> | ||
| 45 | class slice_of | ||
| 46 | { | ||
| 47 | public: | ||
| 48 | /// The buffer type yielded by iteration. | ||
| 49 | using buffer_type = capy::buffer_type<BS>; | ||
| 50 | |||
| 51 | /// The underlying sequence's iterator type. | ||
| 52 | using iterator_type = | ||
| 53 | decltype(capy::begin(std::declval<BS const&>())); | ||
| 54 | |||
| 55 | private: | ||
| 56 | iterator_type first_{}; | ||
| 57 | iterator_type last_{}; | ||
| 58 | std::size_t front_skip_ = 0; // bytes trimmed from *first_ | ||
| 59 | std::size_t back_skip_ = 0; // bytes trimmed from the final buffer | ||
| 60 | |||
| 61 | static buffer_type | ||
| 62 | 34112x | adjust(buffer_type const& b, | |
| 63 | std::size_t front_n, std::size_t back_n) noexcept | ||
| 64 | { | ||
| 65 | if constexpr (std::is_same_v<buffer_type, mutable_buffer>) | ||
| 66 | 17006x | return mutable_buffer( | |
| 67 | 17006x | static_cast<char*>(b.data()) + front_n, | |
| 68 | 34012x | b.size() - front_n - back_n); | |
| 69 | else | ||
| 70 | 17106x | return const_buffer( | |
| 71 | 17106x | static_cast<char const*>(b.data()) + front_n, | |
| 72 | 34212x | b.size() - front_n - back_n); | |
| 73 | } | ||
| 74 | |||
| 75 | public: | ||
| 76 | /// Bidirectional iterator that adjusts the first and last buffers. | ||
| 77 | class const_iterator | ||
| 78 | { | ||
| 79 | iterator_type cur_{}; | ||
| 80 | iterator_type anchor_first_{}; | ||
| 81 | iterator_type anchor_last_{}; | ||
| 82 | std::size_t front_skip_ = 0; | ||
| 83 | std::size_t back_skip_ = 0; | ||
| 84 | |||
| 85 | public: | ||
| 86 | using iterator_category = std::bidirectional_iterator_tag; | ||
| 87 | using value_type = buffer_type; | ||
| 88 | using difference_type = std::ptrdiff_t; | ||
| 89 | using pointer = value_type*; | ||
| 90 | using reference = value_type; | ||
| 91 | |||
| 92 | const_iterator() noexcept = default; | ||
| 93 | |||
| 94 | 51088x | const_iterator( | |
| 95 | iterator_type cur, iterator_type anchor_first, | ||
| 96 | iterator_type anchor_last, std::size_t front_skip, | ||
| 97 | std::size_t back_skip) noexcept | ||
| 98 | 51088x | : cur_(cur) | |
| 99 | 51088x | , anchor_first_(anchor_first) | |
| 100 | 51088x | , anchor_last_(anchor_last) | |
| 101 | 51088x | , front_skip_(front_skip) | |
| 102 | 51088x | , back_skip_(back_skip) | |
| 103 | { | ||
| 104 | 51088x | } | |
| 105 | |||
| 106 | 59163x | bool operator==(const_iterator const& o) const noexcept | |
| 107 | { | ||
| 108 | 59163x | return cur_ == o.cur_; | |
| 109 | } | ||
| 110 | |||
| 111 | 59163x | bool operator!=(const_iterator const& o) const noexcept | |
| 112 | { | ||
| 113 | 59163x | return !(*this == o); | |
| 114 | } | ||
| 115 | |||
| 116 | 34112x | value_type operator*() const noexcept | |
| 117 | { | ||
| 118 | 34112x | buffer_type buf = *cur_; | |
| 119 | 34112x | auto const front_n = (cur_ == anchor_first_) ? front_skip_ : 0; | |
| 120 | 34112x | auto next = cur_; | |
| 121 | 34112x | ++next; | |
| 122 | 34112x | auto const back_n = (next == anchor_last_) ? back_skip_ : 0; | |
| 123 | 34112x | return adjust(buf, front_n, back_n); | |
| 124 | } | ||
| 125 | |||
| 126 | 21911x | const_iterator& operator++() noexcept { ++cur_; return *this; } | |
| 127 | 6436x | const_iterator operator++(int) noexcept | |
| 128 | 6436x | { auto t = *this; ++*this; return t; } | |
| 129 | 12144x | const_iterator& operator--() noexcept { --cur_; return *this; } | |
| 130 | 6072x | const_iterator operator--(int) noexcept | |
| 131 | 6072x | { auto t = *this; --*this; return t; } | |
| 132 | }; | ||
| 133 | |||
| 134 | /// Construct an empty slice. | ||
| 135 | slice_of() noexcept = default; | ||
| 136 | |||
| 137 | /** Construct a view of `[offset, offset + length)` bytes of `bs`. | ||
| 138 | |||
| 139 | @param bs The underlying sequence (must outlive the view). | ||
| 140 | @param offset Bytes skipped from the front. Clamped to the total. | ||
| 141 | @param length Bytes exposed; the default exposes to the end. | ||
| 142 | */ | ||
| 143 | 2291x | slice_of( | |
| 144 | BS const& bs, | ||
| 145 | std::size_t offset, | ||
| 146 | std::size_t length = | ||
| 147 | (std::numeric_limits<std::size_t>::max)()) noexcept | ||
| 148 | 2291x | { | |
| 149 | 2291x | first_ = capy::begin(bs); | |
| 150 | 2291x | last_ = capy::end(bs); | |
| 151 | |||
| 152 | // Position first_/front_skip_ at byte `offset` (single forward pass). | ||
| 153 | 2291x | std::size_t skip = offset; | |
| 154 | 2958x | while (first_ != last_) | |
| 155 | { | ||
| 156 | 2853x | std::size_t const sz = buffer_type(*first_).size(); | |
| 157 | 2853x | if (skip < sz) | |
| 158 | { | ||
| 159 | 2186x | front_skip_ = skip; | |
| 160 | 2186x | break; | |
| 161 | } | ||
| 162 | 667x | skip -= sz; | |
| 163 | 667x | ++first_; | |
| 164 | } | ||
| 165 | |||
| 166 | 2291x | if (first_ == last_) | |
| 167 | 181x | return; // offset at or past the end: empty slice | |
| 168 | 2186x | if (length == (std::numeric_limits<std::size_t>::max)()) | |
| 169 | 1042x | return; // to-end: last_ already end(bs), back_skip_ == 0 | |
| 170 | |||
| 171 | // Walk `length` live bytes forward to fix last_/back_skip_. | ||
| 172 | 1144x | std::size_t left = length; | |
| 173 | 1144x | auto cursor = first_; | |
| 174 | 1144x | std::size_t cursor_front = front_skip_; | |
| 175 | 1641x | while (cursor != last_ && left > 0) | |
| 176 | { | ||
| 177 | 1536x | std::size_t const sz = buffer_type(*cursor).size(); | |
| 178 | 1536x | std::size_t const avail = sz - cursor_front; | |
| 179 | 1536x | if (left <= avail) | |
| 180 | { | ||
| 181 | 1039x | back_skip_ = avail - left; | |
| 182 | 1039x | ++cursor; | |
| 183 | 1039x | last_ = cursor; | |
| 184 | 1039x | return; | |
| 185 | } | ||
| 186 | 497x | left -= avail; | |
| 187 | 497x | ++cursor; | |
| 188 | 497x | cursor_front = 0; | |
| 189 | } | ||
| 190 | 105x | last_ = cursor; | |
| 191 | } | ||
| 192 | |||
| 193 | /** Construct directly from a positioned iterator range. | ||
| 194 | |||
| 195 | Used by `consuming_buffers::data()` to expose its current position | ||
| 196 | without re-walking from the start. | ||
| 197 | */ | ||
| 198 | 335x | slice_of( | |
| 199 | iterator_type first, iterator_type last, | ||
| 200 | std::size_t front_skip = 0, std::size_t back_skip = 0) noexcept | ||
| 201 | 335x | : first_(first) | |
| 202 | 335x | , last_(last) | |
| 203 | 335x | , front_skip_(front_skip) | |
| 204 | 335x | , back_skip_(back_skip) | |
| 205 | { | ||
| 206 | 335x | } | |
| 207 | |||
| 208 | /// Return an iterator to the first buffer. | ||
| 209 | 25534x | const_iterator begin() const noexcept | |
| 210 | { | ||
| 211 | return const_iterator( | ||
| 212 | 25534x | first_, first_, last_, front_skip_, back_skip_); | |
| 213 | } | ||
| 214 | |||
| 215 | /// Return an iterator past the last buffer. | ||
| 216 | 25554x | const_iterator end() const noexcept | |
| 217 | { | ||
| 218 | return const_iterator( | ||
| 219 | 25554x | last_, first_, last_, front_skip_, back_skip_); | |
| 220 | } | ||
| 221 | }; | ||
| 222 | |||
| 223 | } // namespace detail | ||
| 224 | } // namespace capy | ||
| 225 | } // namespace boost | ||
| 226 | |||
| 227 | #endif | ||
| 228 |