include/boost/capy/buffers.hpp
98.9% Lines (456/461)
100.0% List of functions (144/144)
90.5% Branches (67/74)
Functions (144)
Function
Calls
Lines
Branches
Blocks
boost::capy::detail::basic_buffer<unsigned char const, 18446744073709551615ul>::basic_buffer()
:56
611x
100.0%
–
100.0%
boost::capy::detail::basic_buffer<unsigned char, 18446744073709551615ul>::basic_buffer()
:56
585x
100.0%
–
100.0%
boost::capy::detail::basic_buffer<unsigned char const, 18446744073709551615ul>::basic_buffer(unsigned char const*, unsigned long)
:57
37233x
100.0%
–
100.0%
boost::capy::detail::basic_buffer<unsigned char, 18446744073709551615ul>::basic_buffer(unsigned char*, unsigned long)
:57
26478x
100.0%
–
100.0%
boost::capy::mutable_buffer::mutable_buffer()
:105
585x
100.0%
–
100.0%
boost::capy::mutable_buffer::mutable_buffer(void*, unsigned long)
:116
26478x
100.0%
–
100.0%
boost::capy::mutable_buffer::data() const
:135
69625x
100.0%
–
100.0%
boost::capy::mutable_buffer::size() const
:141
107318x
100.0%
–
100.0%
boost::capy::mutable_buffer::operator+=(unsigned long)
:151
25946x
100.0%
100.0%
100.0%
boost::capy::tag_invoke(boost::capy::slice_tag const&, boost::capy::mutable_buffer&, boost::capy::slice_how, unsigned long)
:163
1335x
100.0%
–
100.0%
boost::capy::mutable_buffer::do_slice(boost::capy::slice_how, unsigned long)
:173
1335x
100.0%
80.0%
100.0%
boost::capy::const_buffer::const_buffer()
:206
611x
100.0%
–
100.0%
boost::capy::const_buffer::const_buffer(void const*, unsigned long)
:216
21791x
100.0%
–
100.0%
boost::capy::const_buffer::const_buffer(boost::capy::mutable_buffer const&)
:224
15442x
100.0%
–
100.0%
boost::capy::const_buffer::data() const
:244
63200x
100.0%
–
100.0%
boost::capy::const_buffer::size() const
:250
121334x
100.0%
–
100.0%
boost::capy::const_buffer::operator+=(unsigned long)
:260
26601x
100.0%
100.0%
100.0%
boost::capy::tag_invoke(boost::capy::slice_tag const&, boost::capy::const_buffer&, boost::capy::slice_how, unsigned long)
:272
2640x
100.0%
–
100.0%
boost::capy::const_buffer::do_slice(boost::capy::slice_how, unsigned long)
:282
2640x
94.1%
80.0%
100.0%
boost::capy::const_buffer const* boost::capy::begin_mrdocs_workaround_t::operator()<boost::capy::const_buffer>(boost::capy::const_buffer const&) const
:348
8806x
100.0%
–
100.0%
boost::capy::mutable_buffer const* boost::capy::begin_mrdocs_workaround_t::operator()<boost::capy::mutable_buffer>(boost::capy::mutable_buffer const&) const
:348
10733x
100.0%
–
100.0%
auto boost::capy::begin_mrdocs_workaround_t::operator()<boost::capy::buffer_array<4ul, false> >(boost::capy::buffer_array<4ul, false> const&) const
:355
5511x
100.0%
–
100.0%
auto boost::capy::begin_mrdocs_workaround_t::operator()<boost::capy::buffer_array<4ul, true> >(boost::capy::buffer_array<4ul, true> const&) const
:355
5511x
100.0%
–
100.0%
auto boost::capy::begin_mrdocs_workaround_t::operator()<boost::capy::const_buffer [3]>(boost::capy::const_buffer const (&) [3]) const
:355
2x
100.0%
–
100.0%
auto boost::capy::begin_mrdocs_workaround_t::operator()<boost::capy::consuming_buffers<boost::capy::const_buffer> >(boost::capy::consuming_buffers<boost::capy::const_buffer> const&) const
:355
154x
100.0%
–
100.0%
auto boost::capy::begin_mrdocs_workaround_t::operator()<boost::capy::consuming_buffers<boost::capy::mutable_buffer> >(boost::capy::consuming_buffers<boost::capy::mutable_buffer> const&) const
:355
43x
100.0%
–
100.0%
auto boost::capy::begin_mrdocs_workaround_t::operator()<boost::capy::consuming_buffers<std::array<boost::capy::const_buffer, 2ul> > >(boost::capy::consuming_buffers<std::array<boost::capy::const_buffer, 2ul> > const&) const
:355
70x
100.0%
–
100.0%
auto boost::capy::begin_mrdocs_workaround_t::operator()<boost::capy::consuming_buffers<std::array<boost::capy::mutable_buffer, 2ul> > >(boost::capy::consuming_buffers<std::array<boost::capy::mutable_buffer, 2ul> > const&) const
:355
49x
100.0%
–
100.0%
auto boost::capy::begin_mrdocs_workaround_t::operator()<boost::capy::mutable_buffer [3]>(boost::capy::mutable_buffer const (&) [3]) const
:355
2x
100.0%
–
100.0%
auto boost::capy::begin_mrdocs_workaround_t::operator()<boost::capy::slice_of<std::array<boost::capy::const_buffer, 3ul> > >(boost::capy::slice_of<std::array<boost::capy::const_buffer, 3ul> > const&) const
:355
28x
100.0%
–
100.0%
auto boost::capy::begin_mrdocs_workaround_t::operator()<boost::capy::slice_of<std::span<boost::capy::const_buffer const, 18446744073709551615ul> > >(boost::capy::slice_of<std::span<boost::capy::const_buffer const, 18446744073709551615ul> > const&) const
:355
330x
100.0%
–
100.0%
auto boost::capy::begin_mrdocs_workaround_t::operator()<boost::capy::slice_of<std::span<boost::capy::mutable_buffer const, 18446744073709551615ul> > >(boost::capy::slice_of<std::span<boost::capy::mutable_buffer const, 18446744073709551615ul> > const&) const
:355
330x
100.0%
–
100.0%
auto boost::capy::begin_mrdocs_workaround_t::operator()<boost::capy::slice_of<std::vector<boost::capy::const_buffer, std::allocator<boost::capy::const_buffer> > > >(boost::capy::slice_of<std::vector<boost::capy::const_buffer, std::allocator<boost::capy::const_buffer> > > const&) const
:355
1934x
100.0%
–
100.0%
auto boost::capy::begin_mrdocs_workaround_t::operator()<std::array<boost::capy::const_buffer, 2ul> >(std::array<boost::capy::const_buffer, 2ul> const&) const
:355
11381x
100.0%
–
100.0%
auto boost::capy::begin_mrdocs_workaround_t::operator()<std::array<boost::capy::const_buffer, 3ul> >(std::array<boost::capy::const_buffer, 3ul> const&) const
:355
76x
100.0%
–
100.0%
auto boost::capy::begin_mrdocs_workaround_t::operator()<std::array<boost::capy::mutable_buffer, 20ul> >(std::array<boost::capy::mutable_buffer, 20ul> const&) const
:355
16x
100.0%
–
100.0%
auto boost::capy::begin_mrdocs_workaround_t::operator()<std::array<boost::capy::mutable_buffer, 2ul> >(std::array<boost::capy::mutable_buffer, 2ul> const&) const
:355
11466x
100.0%
–
100.0%
auto boost::capy::begin_mrdocs_workaround_t::operator()<std::array<boost::capy::mutable_buffer, 3ul> >(std::array<boost::capy::mutable_buffer, 3ul> const&) const
:355
2x
100.0%
–
100.0%
auto boost::capy::begin_mrdocs_workaround_t::operator()<std::span<boost::capy::const_buffer const, 18446744073709551615ul> >(std::span<boost::capy::const_buffer const, 18446744073709551615ul> const&) const
:355
5773x
100.0%
–
100.0%
auto boost::capy::begin_mrdocs_workaround_t::operator()<std::span<boost::capy::const_buffer, 18446744073709551615ul> >(std::span<boost::capy::const_buffer, 18446744073709551615ul> const&) const
:355
695x
100.0%
–
100.0%
auto boost::capy::begin_mrdocs_workaround_t::operator()<std::span<boost::capy::const_buffer, 3ul> >(std::span<boost::capy::const_buffer, 3ul> const&) const
:355
2x
100.0%
–
100.0%
auto boost::capy::begin_mrdocs_workaround_t::operator()<std::span<boost::capy::mutable_buffer const, 18446744073709551615ul> >(std::span<boost::capy::mutable_buffer const, 18446744073709551615ul> const&) const
:355
7051x
100.0%
–
100.0%
auto boost::capy::begin_mrdocs_workaround_t::operator()<std::span<boost::capy::mutable_buffer, 18446744073709551615ul> >(std::span<boost::capy::mutable_buffer, 18446744073709551615ul> const&) const
:355
104x
100.0%
–
100.0%
auto boost::capy::begin_mrdocs_workaround_t::operator()<std::span<boost::capy::mutable_buffer, 3ul> >(std::span<boost::capy::mutable_buffer, 3ul> const&) const
:355
2x
100.0%
–
100.0%
auto boost::capy::begin_mrdocs_workaround_t::operator()<std::vector<boost::capy::const_buffer, std::allocator<boost::capy::const_buffer> > >(std::vector<boost::capy::const_buffer, std::allocator<boost::capy::const_buffer> > const&) const
:355
5383x
100.0%
–
100.0%
auto boost::capy::begin_mrdocs_workaround_t::operator()<std::vector<boost::capy::mutable_buffer, std::allocator<boost::capy::mutable_buffer> > >(std::vector<boost::capy::mutable_buffer, std::allocator<boost::capy::mutable_buffer> > const&) const
:355
29x
100.0%
–
100.0%
auto boost::capy::begin_mrdocs_workaround_t::operator()<boost::capy::buffer_array<4ul, false> >(boost::capy::buffer_array<4ul, false>&) const
:362
4416x
100.0%
–
100.0%
auto boost::capy::begin_mrdocs_workaround_t::operator()<boost::capy::buffer_array<4ul, true> >(boost::capy::buffer_array<4ul, true>&) const
:362
4416x
100.0%
–
100.0%
auto boost::capy::begin_mrdocs_workaround_t::operator()<boost::capy::slice_of<std::span<boost::capy::const_buffer const, 18446744073709551615ul> > >(boost::capy::slice_of<std::span<boost::capy::const_buffer const, 18446744073709551615ul> >&) const
:362
176x
100.0%
–
100.0%
auto boost::capy::begin_mrdocs_workaround_t::operator()<boost::capy::slice_of<std::span<boost::capy::mutable_buffer const, 18446744073709551615ul> > >(boost::capy::slice_of<std::span<boost::capy::mutable_buffer const, 18446744073709551615ul> >&) const
:362
176x
100.0%
–
100.0%
auto boost::capy::begin_mrdocs_workaround_t::operator()<boost::capy::slice_of<std::vector<boost::capy::const_buffer, std::allocator<boost::capy::const_buffer> > > >(boost::capy::slice_of<std::vector<boost::capy::const_buffer, std::allocator<boost::capy::const_buffer> > >&) const
:362
352x
100.0%
–
100.0%
auto boost::capy::begin_mrdocs_workaround_t::operator()<std::array<boost::capy::const_buffer, 2ul> >(std::array<boost::capy::const_buffer, 2ul>&) const
:362
4416x
100.0%
–
100.0%
auto boost::capy::begin_mrdocs_workaround_t::operator()<std::array<boost::capy::const_buffer, 3ul> >(std::array<boost::capy::const_buffer, 3ul>&) const
:362
14x
100.0%
–
100.0%
auto boost::capy::begin_mrdocs_workaround_t::operator()<std::array<boost::capy::mutable_buffer, 2ul> >(std::array<boost::capy::mutable_buffer, 2ul>&) const
:362
4416x
100.0%
–
100.0%
auto boost::capy::begin_mrdocs_workaround_t::operator()<std::span<boost::capy::const_buffer const, 18446744073709551615ul> >(std::span<boost::capy::const_buffer const, 18446744073709551615ul>&) const
:362
48x
100.0%
–
100.0%
auto boost::capy::begin_mrdocs_workaround_t::operator()<std::span<boost::capy::mutable_buffer const, 18446744073709551615ul> >(std::span<boost::capy::mutable_buffer const, 18446744073709551615ul>&) const
:362
48x
100.0%
–
100.0%
auto boost::capy::begin_mrdocs_workaround_t::operator()<std::vector<boost::capy::const_buffer, std::allocator<boost::capy::const_buffer> > >(std::vector<boost::capy::const_buffer, std::allocator<boost::capy::const_buffer> >&) const
:362
96x
100.0%
–
100.0%
boost::capy::const_buffer const* boost::capy::end_mrdocs_workaround_t::operator()<boost::capy::const_buffer>(boost::capy::const_buffer const&) const
:376
8566x
100.0%
–
100.0%
boost::capy::mutable_buffer const* boost::capy::end_mrdocs_workaround_t::operator()<boost::capy::mutable_buffer>(boost::capy::mutable_buffer const&) const
:376
10733x
91.7%
–
100.0%
auto boost::capy::end_mrdocs_workaround_t::operator()<boost::capy::buffer_array<4ul, false> >(boost::capy::buffer_array<4ul, false> const&) const
:383
5511x
100.0%
–
100.0%
auto boost::capy::end_mrdocs_workaround_t::operator()<boost::capy::buffer_array<4ul, true> >(boost::capy::buffer_array<4ul, true> const&) const
:383
5511x
100.0%
–
100.0%
auto boost::capy::end_mrdocs_workaround_t::operator()<boost::capy::const_buffer [3]>(boost::capy::const_buffer const (&) [3]) const
:383
2x
100.0%
–
100.0%
auto boost::capy::end_mrdocs_workaround_t::operator()<boost::capy::consuming_buffers<boost::capy::const_buffer> >(boost::capy::consuming_buffers<boost::capy::const_buffer> const&) const
:383
154x
100.0%
–
100.0%
auto boost::capy::end_mrdocs_workaround_t::operator()<boost::capy::consuming_buffers<boost::capy::mutable_buffer> >(boost::capy::consuming_buffers<boost::capy::mutable_buffer> const&) const
:383
43x
100.0%
–
100.0%
auto boost::capy::end_mrdocs_workaround_t::operator()<boost::capy::consuming_buffers<std::array<boost::capy::const_buffer, 2ul> > >(boost::capy::consuming_buffers<std::array<boost::capy::const_buffer, 2ul> > const&) const
:383
70x
100.0%
–
100.0%
auto boost::capy::end_mrdocs_workaround_t::operator()<boost::capy::consuming_buffers<std::array<boost::capy::mutable_buffer, 2ul> > >(boost::capy::consuming_buffers<std::array<boost::capy::mutable_buffer, 2ul> > const&) const
:383
49x
100.0%
–
100.0%
auto boost::capy::end_mrdocs_workaround_t::operator()<boost::capy::mutable_buffer [3]>(boost::capy::mutable_buffer const (&) [3]) const
:383
2x
100.0%
–
100.0%
auto boost::capy::end_mrdocs_workaround_t::operator()<boost::capy::slice_of<std::array<boost::capy::const_buffer, 3ul> > >(boost::capy::slice_of<std::array<boost::capy::const_buffer, 3ul> > const&) const
:383
28x
100.0%
–
100.0%
auto boost::capy::end_mrdocs_workaround_t::operator()<boost::capy::slice_of<std::span<boost::capy::const_buffer const, 18446744073709551615ul> > >(boost::capy::slice_of<std::span<boost::capy::const_buffer const, 18446744073709551615ul> > const&) const
:383
330x
100.0%
–
100.0%
auto boost::capy::end_mrdocs_workaround_t::operator()<boost::capy::slice_of<std::span<boost::capy::mutable_buffer const, 18446744073709551615ul> > >(boost::capy::slice_of<std::span<boost::capy::mutable_buffer const, 18446744073709551615ul> > const&) const
:383
330x
100.0%
–
100.0%
auto boost::capy::end_mrdocs_workaround_t::operator()<boost::capy::slice_of<std::vector<boost::capy::const_buffer, std::allocator<boost::capy::const_buffer> > > >(boost::capy::slice_of<std::vector<boost::capy::const_buffer, std::allocator<boost::capy::const_buffer> > > const&) const
:383
1934x
100.0%
–
100.0%
auto boost::capy::end_mrdocs_workaround_t::operator()<std::array<boost::capy::const_buffer, 2ul> >(std::array<boost::capy::const_buffer, 2ul> const&) const
:383
8846x
100.0%
–
100.0%
auto boost::capy::end_mrdocs_workaround_t::operator()<std::array<boost::capy::const_buffer, 3ul> >(std::array<boost::capy::const_buffer, 3ul> const&) const
:383
3x
100.0%
–
100.0%
auto boost::capy::end_mrdocs_workaround_t::operator()<std::array<boost::capy::mutable_buffer, 20ul> >(std::array<boost::capy::mutable_buffer, 20ul> const&) const
:383
16x
100.0%
–
100.0%
auto boost::capy::end_mrdocs_workaround_t::operator()<std::array<boost::capy::mutable_buffer, 2ul> >(std::array<boost::capy::mutable_buffer, 2ul> const&) const
:383
8931x
100.0%
–
100.0%
auto boost::capy::end_mrdocs_workaround_t::operator()<std::array<boost::capy::mutable_buffer, 3ul> >(std::array<boost::capy::mutable_buffer, 3ul> const&) const
:383
2x
100.0%
–
100.0%
auto boost::capy::end_mrdocs_workaround_t::operator()<std::span<boost::capy::const_buffer const, 18446744073709551615ul> >(std::span<boost::capy::const_buffer const, 18446744073709551615ul> const&) const
:383
357x
100.0%
–
100.0%
auto boost::capy::end_mrdocs_workaround_t::operator()<std::span<boost::capy::const_buffer, 18446744073709551615ul> >(std::span<boost::capy::const_buffer, 18446744073709551615ul> const&) const
:383
695x
100.0%
–
100.0%
auto boost::capy::end_mrdocs_workaround_t::operator()<std::span<boost::capy::const_buffer, 3ul> >(std::span<boost::capy::const_buffer, 3ul> const&) const
:383
2x
100.0%
–
100.0%
auto boost::capy::end_mrdocs_workaround_t::operator()<std::span<boost::capy::mutable_buffer const, 18446744073709551615ul> >(std::span<boost::capy::mutable_buffer const, 18446744073709551615ul> const&) const
:383
1635x
100.0%
–
100.0%
auto boost::capy::end_mrdocs_workaround_t::operator()<std::span<boost::capy::mutable_buffer, 18446744073709551615ul> >(std::span<boost::capy::mutable_buffer, 18446744073709551615ul> const&) const
:383
104x
100.0%
–
100.0%
auto boost::capy::end_mrdocs_workaround_t::operator()<std::span<boost::capy::mutable_buffer, 3ul> >(std::span<boost::capy::mutable_buffer, 3ul> const&) const
:383
2x
100.0%
–
100.0%
auto boost::capy::end_mrdocs_workaround_t::operator()<std::vector<boost::capy::const_buffer, std::allocator<boost::capy::const_buffer> > >(std::vector<boost::capy::const_buffer, std::allocator<boost::capy::const_buffer> > const&) const
:383
48x
100.0%
–
100.0%
auto boost::capy::end_mrdocs_workaround_t::operator()<std::vector<boost::capy::mutable_buffer, std::allocator<boost::capy::mutable_buffer> > >(std::vector<boost::capy::mutable_buffer, std::allocator<boost::capy::mutable_buffer> > const&) const
:383
27x
100.0%
–
100.0%
auto boost::capy::end_mrdocs_workaround_t::operator()<boost::capy::buffer_array<4ul, false> >(boost::capy::buffer_array<4ul, false>&) const
:390
4416x
100.0%
–
100.0%
auto boost::capy::end_mrdocs_workaround_t::operator()<boost::capy::buffer_array<4ul, true> >(boost::capy::buffer_array<4ul, true>&) const
:390
4416x
100.0%
–
100.0%
auto boost::capy::end_mrdocs_workaround_t::operator()<boost::capy::slice_of<std::span<boost::capy::const_buffer const, 18446744073709551615ul> > >(boost::capy::slice_of<std::span<boost::capy::const_buffer const, 18446744073709551615ul> >&) const
:390
176x
100.0%
–
100.0%
auto boost::capy::end_mrdocs_workaround_t::operator()<boost::capy::slice_of<std::span<boost::capy::mutable_buffer const, 18446744073709551615ul> > >(boost::capy::slice_of<std::span<boost::capy::mutable_buffer const, 18446744073709551615ul> >&) const
:390
176x
100.0%
–
100.0%
auto boost::capy::end_mrdocs_workaround_t::operator()<boost::capy::slice_of<std::vector<boost::capy::const_buffer, std::allocator<boost::capy::const_buffer> > > >(boost::capy::slice_of<std::vector<boost::capy::const_buffer, std::allocator<boost::capy::const_buffer> > >&) const
:390
352x
100.0%
–
100.0%
auto boost::capy::end_mrdocs_workaround_t::operator()<std::array<boost::capy::const_buffer, 2ul> >(std::array<boost::capy::const_buffer, 2ul>&) const
:390
4416x
100.0%
–
100.0%
auto boost::capy::end_mrdocs_workaround_t::operator()<std::array<boost::capy::const_buffer, 3ul> >(std::array<boost::capy::const_buffer, 3ul>&) const
:390
14x
100.0%
–
100.0%
auto boost::capy::end_mrdocs_workaround_t::operator()<std::array<boost::capy::mutable_buffer, 2ul> >(std::array<boost::capy::mutable_buffer, 2ul>&) const
:390
4416x
100.0%
–
100.0%
auto boost::capy::end_mrdocs_workaround_t::operator()<std::span<boost::capy::const_buffer const, 18446744073709551615ul> >(std::span<boost::capy::const_buffer const, 18446744073709551615ul>&) const
:390
48x
100.0%
–
100.0%
auto boost::capy::end_mrdocs_workaround_t::operator()<std::span<boost::capy::mutable_buffer const, 18446744073709551615ul> >(std::span<boost::capy::mutable_buffer const, 18446744073709551615ul>&) const
:390
48x
100.0%
–
100.0%
auto boost::capy::end_mrdocs_workaround_t::operator()<std::vector<boost::capy::const_buffer, std::allocator<boost::capy::const_buffer> > >(std::vector<boost::capy::const_buffer, std::allocator<boost::capy::const_buffer> >&) const
:390
96x
100.0%
–
100.0%
unsigned long boost::capy::tag_invoke<boost::capy::const_buffer [3]>(boost::capy::size_tag const&, boost::capy::const_buffer const (&) [3])
:400
1x
100.0%
100.0%
100.0%
unsigned long boost::capy::tag_invoke<boost::capy::const_buffer>(boost::capy::size_tag const&, boost::capy::const_buffer const&)
:400
5001x
100.0%
100.0%
100.0%
unsigned long boost::capy::tag_invoke<boost::capy::consuming_buffers<boost::capy::const_buffer> >(boost::capy::size_tag const&, boost::capy::consuming_buffers<boost::capy::const_buffer> const&)
:400
38x
100.0%
100.0%
100.0%
unsigned long boost::capy::tag_invoke<boost::capy::consuming_buffers<boost::capy::mutable_buffer> >(boost::capy::size_tag const&, boost::capy::consuming_buffers<boost::capy::mutable_buffer> const&)
:400
3x
100.0%
100.0%
100.0%
unsigned long boost::capy::tag_invoke<boost::capy::consuming_buffers<std::array<boost::capy::const_buffer, 2ul> > >(boost::capy::size_tag const&, boost::capy::consuming_buffers<std::array<boost::capy::const_buffer, 2ul> > const&)
:400
14x
100.0%
100.0%
100.0%
unsigned long boost::capy::tag_invoke<boost::capy::consuming_buffers<std::array<boost::capy::mutable_buffer, 2ul> > >(boost::capy::size_tag const&, boost::capy::consuming_buffers<std::array<boost::capy::mutable_buffer, 2ul> > const&)
:400
1x
100.0%
100.0%
100.0%
unsigned long boost::capy::tag_invoke<boost::capy::mutable_buffer [3]>(boost::capy::size_tag const&, boost::capy::mutable_buffer const (&) [3])
:400
1x
100.0%
100.0%
100.0%
unsigned long boost::capy::tag_invoke<boost::capy::mutable_buffer>(boost::capy::size_tag const&, boost::capy::mutable_buffer const&)
:400
738x
100.0%
100.0%
100.0%
unsigned long boost::capy::tag_invoke<boost::capy::slice_of<std::array<boost::capy::const_buffer, 3ul> > >(boost::capy::size_tag const&, boost::capy::slice_of<std::array<boost::capy::const_buffer, 3ul> > const&)
:400
14x
100.0%
100.0%
100.0%
unsigned long boost::capy::tag_invoke<boost::capy::slice_of<std::span<boost::capy::const_buffer const, 18446744073709551615ul> > >(boost::capy::size_tag const&, boost::capy::slice_of<std::span<boost::capy::const_buffer const, 18446744073709551615ul> > const&)
:400
110x
100.0%
100.0%
100.0%
unsigned long boost::capy::tag_invoke<boost::capy::slice_of<std::span<boost::capy::mutable_buffer const, 18446744073709551615ul> > >(boost::capy::size_tag const&, boost::capy::slice_of<std::span<boost::capy::mutable_buffer const, 18446744073709551615ul> > const&)
:400
110x
100.0%
100.0%
100.0%
unsigned long boost::capy::tag_invoke<boost::capy::slice_of<std::vector<boost::capy::const_buffer, std::allocator<boost::capy::const_buffer> > > >(boost::capy::size_tag const&, boost::capy::slice_of<std::vector<boost::capy::const_buffer, std::allocator<boost::capy::const_buffer> > > const&)
:400
986x
100.0%
100.0%
100.0%
unsigned long boost::capy::tag_invoke<std::array<boost::capy::const_buffer, 2ul> >(boost::capy::size_tag const&, std::array<boost::capy::const_buffer, 2ul> const&)
:400
2908x
100.0%
100.0%
100.0%
unsigned long boost::capy::tag_invoke<std::array<boost::capy::const_buffer, 3ul> >(boost::capy::size_tag const&, std::array<boost::capy::const_buffer, 3ul> const&)
:400
2x
100.0%
100.0%
100.0%
unsigned long boost::capy::tag_invoke<std::array<boost::capy::mutable_buffer, 2ul> >(boost::capy::size_tag const&, std::array<boost::capy::mutable_buffer, 2ul> const&)
:400
2838x
100.0%
100.0%
100.0%
unsigned long boost::capy::tag_invoke<std::array<boost::capy::mutable_buffer, 3ul> >(boost::capy::size_tag const&, std::array<boost::capy::mutable_buffer, 3ul> const&)
:400
1x
100.0%
100.0%
100.0%
unsigned long boost::capy::tag_invoke<std::span<boost::capy::const_buffer const, 18446744073709551615ul> >(boost::capy::size_tag const&, std::span<boost::capy::const_buffer const, 18446744073709551615ul> const&)
:400
131x
100.0%
100.0%
100.0%
unsigned long boost::capy::tag_invoke<std::span<boost::capy::const_buffer, 18446744073709551615ul> >(boost::capy::size_tag const&, std::span<boost::capy::const_buffer, 18446744073709551615ul> const&)
:400
222x
100.0%
100.0%
100.0%
unsigned long boost::capy::tag_invoke<std::span<boost::capy::const_buffer, 3ul> >(boost::capy::size_tag const&, std::span<boost::capy::const_buffer, 3ul> const&)
:400
1x
100.0%
100.0%
100.0%
unsigned long boost::capy::tag_invoke<std::span<boost::capy::mutable_buffer const, 18446744073709551615ul> >(boost::capy::size_tag const&, std::span<boost::capy::mutable_buffer const, 18446744073709551615ul> const&)
:400
163x
100.0%
100.0%
100.0%
unsigned long boost::capy::tag_invoke<std::span<boost::capy::mutable_buffer, 3ul> >(boost::capy::size_tag const&, std::span<boost::capy::mutable_buffer, 3ul> const&)
:400
1x
100.0%
100.0%
100.0%
unsigned long boost::capy::tag_invoke<std::vector<boost::capy::const_buffer, std::allocator<boost::capy::const_buffer> > >(boost::capy::size_tag const&, std::vector<boost::capy::const_buffer, std::allocator<boost::capy::const_buffer> > const&)
:400
1x
100.0%
100.0%
100.0%
unsigned long boost::capy::buffer_size_mrdocs_workaround_t::operator()<boost::capy::const_buffer [3]>(boost::capy::const_buffer const (&) [3]) const
:427
1x
100.0%
–
100.0%
unsigned long boost::capy::buffer_size_mrdocs_workaround_t::operator()<boost::capy::const_buffer>(boost::capy::const_buffer const&) const
:427
5001x
90.0%
–
100.0%
unsigned long boost::capy::buffer_size_mrdocs_workaround_t::operator()<boost::capy::consuming_buffers<boost::capy::const_buffer> >(boost::capy::consuming_buffers<boost::capy::const_buffer> const&) const
:427
38x
100.0%
–
100.0%
unsigned long boost::capy::buffer_size_mrdocs_workaround_t::operator()<boost::capy::consuming_buffers<boost::capy::mutable_buffer> >(boost::capy::consuming_buffers<boost::capy::mutable_buffer> const&) const
:427
2x
100.0%
–
100.0%
unsigned long boost::capy::buffer_size_mrdocs_workaround_t::operator()<boost::capy::consuming_buffers<std::array<boost::capy::const_buffer, 2ul> > >(boost::capy::consuming_buffers<std::array<boost::capy::const_buffer, 2ul> > const&) const
:427
14x
100.0%
–
100.0%
unsigned long boost::capy::buffer_size_mrdocs_workaround_t::operator()<boost::capy::mutable_buffer [3]>(boost::capy::mutable_buffer const (&) [3]) const
:427
1x
100.0%
–
100.0%
unsigned long boost::capy::buffer_size_mrdocs_workaround_t::operator()<boost::capy::mutable_buffer>(boost::capy::mutable_buffer const&) const
:427
738x
100.0%
–
100.0%
unsigned long boost::capy::buffer_size_mrdocs_workaround_t::operator()<boost::capy::slice_of<std::array<boost::capy::const_buffer, 3ul> > >(boost::capy::slice_of<std::array<boost::capy::const_buffer, 3ul> > const&) const
:427
14x
100.0%
–
100.0%
unsigned long boost::capy::buffer_size_mrdocs_workaround_t::operator()<boost::capy::slice_of<std::span<boost::capy::const_buffer const, 18446744073709551615ul> > >(boost::capy::slice_of<std::span<boost::capy::const_buffer const, 18446744073709551615ul> > const&) const
:427
110x
100.0%
–
100.0%
unsigned long boost::capy::buffer_size_mrdocs_workaround_t::operator()<boost::capy::slice_of<std::span<boost::capy::mutable_buffer const, 18446744073709551615ul> > >(boost::capy::slice_of<std::span<boost::capy::mutable_buffer const, 18446744073709551615ul> > const&) const
:427
110x
100.0%
–
100.0%
unsigned long boost::capy::buffer_size_mrdocs_workaround_t::operator()<boost::capy::slice_of<std::vector<boost::capy::const_buffer, std::allocator<boost::capy::const_buffer> > > >(boost::capy::slice_of<std::vector<boost::capy::const_buffer, std::allocator<boost::capy::const_buffer> > > const&) const
:427
986x
100.0%
–
100.0%
unsigned long boost::capy::buffer_size_mrdocs_workaround_t::operator()<std::array<boost::capy::const_buffer, 2ul> >(std::array<boost::capy::const_buffer, 2ul> const&) const
:427
171x
100.0%
–
100.0%
unsigned long boost::capy::buffer_size_mrdocs_workaround_t::operator()<std::array<boost::capy::const_buffer, 3ul> >(std::array<boost::capy::const_buffer, 3ul> const&) const
:427
2x
100.0%
–
100.0%
unsigned long boost::capy::buffer_size_mrdocs_workaround_t::operator()<std::array<boost::capy::mutable_buffer, 2ul> >(std::array<boost::capy::mutable_buffer, 2ul> const&) const
:427
101x
100.0%
–
100.0%
unsigned long boost::capy::buffer_size_mrdocs_workaround_t::operator()<std::array<boost::capy::mutable_buffer, 3ul> >(std::array<boost::capy::mutable_buffer, 3ul> const&) const
:427
1x
100.0%
–
100.0%
unsigned long boost::capy::buffer_size_mrdocs_workaround_t::operator()<std::span<boost::capy::const_buffer const, 18446744073709551615ul> >(std::span<boost::capy::const_buffer const, 18446744073709551615ul> const&) const
:427
131x
100.0%
–
100.0%
unsigned long boost::capy::buffer_size_mrdocs_workaround_t::operator()<std::span<boost::capy::const_buffer, 18446744073709551615ul> >(std::span<boost::capy::const_buffer, 18446744073709551615ul> const&) const
:427
222x
100.0%
–
100.0%
unsigned long boost::capy::buffer_size_mrdocs_workaround_t::operator()<std::span<boost::capy::const_buffer, 3ul> >(std::span<boost::capy::const_buffer, 3ul> const&) const
:427
1x
100.0%
–
100.0%
unsigned long boost::capy::buffer_size_mrdocs_workaround_t::operator()<std::span<boost::capy::mutable_buffer const, 18446744073709551615ul> >(std::span<boost::capy::mutable_buffer const, 18446744073709551615ul> const&) const
:427
163x
100.0%
–
100.0%
unsigned long boost::capy::buffer_size_mrdocs_workaround_t::operator()<std::span<boost::capy::mutable_buffer, 3ul> >(std::span<boost::capy::mutable_buffer, 3ul> const&) const
:427
1x
100.0%
–
100.0%
unsigned long boost::capy::buffer_size_mrdocs_workaround_t::operator()<std::vector<boost::capy::const_buffer, std::allocator<boost::capy::const_buffer> > >(std::vector<boost::capy::const_buffer, std::allocator<boost::capy::const_buffer> > const&) const
:427
1x
100.0%
–
100.0%
bool boost::capy::buffer_empty_mrdocs_workaround_t::operator()<boost::capy::mutable_buffer>(boost::capy::mutable_buffer const&) const
:442
377x
100.0%
100.0%
100.0%
bool boost::capy::buffer_empty_mrdocs_workaround_t::operator()<std::span<boost::capy::const_buffer const, 18446744073709551615ul> >(std::span<boost::capy::const_buffer const, 18446744073709551615ul> const&) const
:442
101x
87.5%
50.0%
86.0%
bool boost::capy::buffer_empty_mrdocs_workaround_t::operator()<std::span<boost::capy::const_buffer, 18446744073709551615ul> >(std::span<boost::capy::const_buffer, 18446744073709551615ul> const&) const
:442
148x
87.5%
50.0%
86.0%
bool boost::capy::buffer_empty_mrdocs_workaround_t::operator()<std::span<boost::capy::mutable_buffer const, 18446744073709551615ul> >(std::span<boost::capy::mutable_buffer const, 18446744073709551615ul> const&) const
:442
791x
100.0%
75.0%
93.0%
decltype (static_cast<unsigned long>({parm#2}-{parm#1})) boost::capy::detail::length_impl<boost::capy::const_buffer const*>(boost::capy::const_buffer const*, boost::capy::const_buffer const*, int)
:463
240x
100.0%
–
100.0%
unsigned long boost::capy::buffer_length<boost::capy::const_buffer>(boost::capy::const_buffer const&)
:494
240x
100.0%
–
100.0%
| Line | Branch | TLA | Hits | Source Code |
|---|---|---|---|---|
| 1 | // | |||
| 2 | // Copyright (c) 2025 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/capy | |||
| 8 | // | |||
| 9 | ||||
| 10 | #ifndef BOOST_CAPY_BUFFERS_HPP | |||
| 11 | #define BOOST_CAPY_BUFFERS_HPP | |||
| 12 | ||||
| 13 | #include <boost/capy/detail/config.hpp> | |||
| 14 | #include <concepts> | |||
| 15 | #include <cstddef> | |||
| 16 | #include <iterator> | |||
| 17 | #include <memory> | |||
| 18 | #include <ranges> | |||
| 19 | #include <type_traits> | |||
| 20 | ||||
| 21 | // https://www.boost.org/doc/libs/1_65_0/doc/html/boost_asio/reference/ConstBufferSequence.html | |||
| 22 | ||||
| 23 | namespace boost { | |||
| 24 | ||||
| 25 | namespace asio { | |||
| 26 | class const_buffer; | |||
| 27 | class mutable_buffer; | |||
| 28 | } // asio | |||
| 29 | ||||
| 30 | namespace capy { | |||
| 31 | ||||
| 32 | class const_buffer; | |||
| 33 | class mutable_buffer; | |||
| 34 | ||||
| 35 | namespace detail { | |||
| 36 | ||||
| 37 | // satisfies Asio's buffer constructors, CANNOT be removed! | |||
| 38 | template<class T, std::size_t Extent = (std::size_t)(-1)> | |||
| 39 | class basic_buffer | |||
| 40 | { | |||
| 41 | constexpr auto data() const noexcept -> | |||
| 42 | std::conditional_t<std::is_const_v<T>, void const*, void*> | |||
| 43 | { | |||
| 44 | return p_; | |||
| 45 | } | |||
| 46 | ||||
| 47 | constexpr std::size_t size() const noexcept | |||
| 48 | { | |||
| 49 | return n_; | |||
| 50 | } | |||
| 51 | ||||
| 52 | friend class capy::const_buffer; | |||
| 53 | friend class capy::mutable_buffer; | |||
| 54 | friend class asio::const_buffer; | |||
| 55 | friend class asio::mutable_buffer; | |||
| 56 | 1196x | basic_buffer() = default; | ||
| 57 | 63711x | constexpr basic_buffer(T* p, std::size_t n) noexcept : p_(p), n_(n) {} | ||
| 58 | constexpr basic_buffer<T, (std::size_t)(-1)> subspan( | |||
| 59 | std::size_t, std::size_t = (std::size_t)(-1)) const noexcept; | |||
| 60 | ||||
| 61 | T* p_ = nullptr; | |||
| 62 | std::size_t n_ = 0; | |||
| 63 | }; | |||
| 64 | ||||
| 65 | } // detail | |||
| 66 | ||||
| 67 | //------------------------------------------------ | |||
| 68 | ||||
| 69 | /// Tag type for customizing `buffer_size` via `tag_invoke`. | |||
| 70 | struct size_tag {}; | |||
| 71 | ||||
| 72 | /// Tag type for customizing slice operations via `tag_invoke`. | |||
| 73 | struct slice_tag {}; | |||
| 74 | ||||
| 75 | /** Constants for slice customization. | |||
| 76 | ||||
| 77 | Passed to `tag_invoke` overloads to specify which portion | |||
| 78 | of a buffer sequence to retain. | |||
| 79 | */ | |||
| 80 | enum class slice_how | |||
| 81 | { | |||
| 82 | /// Remove bytes from the front of the sequence. | |||
| 83 | remove_prefix, | |||
| 84 | ||||
| 85 | /// Keep only the first N bytes. | |||
| 86 | keep_prefix | |||
| 87 | }; | |||
| 88 | ||||
| 89 | //------------------------------------------------ | |||
| 90 | ||||
| 91 | /** A reference to a contiguous region of writable memory. | |||
| 92 | ||||
| 93 | Represents a pointer and size pair for a modifiable byte range. | |||
| 94 | Does not own the memory. Satisfies `MutableBufferSequence` (as a | |||
| 95 | single-element sequence) and is implicitly convertible to | |||
| 96 | `const_buffer`. | |||
| 97 | ||||
| 98 | @see const_buffer, MutableBufferSequence | |||
| 99 | */ | |||
| 100 | class mutable_buffer | |||
| 101 | : public detail::basic_buffer<unsigned char> | |||
| 102 | { | |||
| 103 | public: | |||
| 104 | /// Construct an empty buffer. | |||
| 105 | 585x | mutable_buffer() = default; | ||
| 106 | ||||
| 107 | /// Copy constructor. | |||
| 108 | mutable_buffer( | |||
| 109 | mutable_buffer const&) = default; | |||
| 110 | ||||
| 111 | /// Copy assignment. | |||
| 112 | mutable_buffer& operator=( | |||
| 113 | mutable_buffer const&) = default; | |||
| 114 | ||||
| 115 | /// Construct from pointer and size. | |||
| 116 | 26478x | constexpr mutable_buffer( | ||
| 117 | void* data, std::size_t size) noexcept | |||
| 118 | 26478x | : basic_buffer<unsigned char>( | ||
| 119 | 26478x | static_cast<unsigned char*>(data), size) | ||
| 120 | { | |||
| 121 | 26478x | } | ||
| 122 | ||||
| 123 | /// Construct from Asio mutable_buffer. | |||
| 124 | template<class MutableBuffer> | |||
| 125 | requires std::same_as<MutableBuffer, asio::mutable_buffer> | |||
| 126 | constexpr mutable_buffer( | |||
| 127 | MutableBuffer const& b) noexcept | |||
| 128 | : basic_buffer<unsigned char>( | |||
| 129 | static_cast<unsigned char*>( | |||
| 130 | b.data()), b.size()) | |||
| 131 | { | |||
| 132 | } | |||
| 133 | ||||
| 134 | /// Return a pointer to the memory region. | |||
| 135 | 69625x | constexpr void* data() const noexcept | ||
| 136 | { | |||
| 137 | 69625x | return p_; | ||
| 138 | } | |||
| 139 | ||||
| 140 | /// Return the size in bytes. | |||
| 141 | 107318x | constexpr std::size_t size() const noexcept | ||
| 142 | { | |||
| 143 | 107318x | return n_; | ||
| 144 | } | |||
| 145 | ||||
| 146 | /** Advance the buffer start, shrinking the region. | |||
| 147 | ||||
| 148 | @param n Bytes to skip. Clamped to `size()`. | |||
| 149 | */ | |||
| 150 | mutable_buffer& | |||
| 151 | 25946x | operator+=(std::size_t n) noexcept | ||
| 152 | { | |||
| 153 |
2/2✓ Branch 0 taken 17 times.
✓ Branch 1 taken 25929 times.
|
25946x | if( n > n_) | |
| 154 | 17x | n = n_; | ||
| 155 | 25946x | p_ += n; | ||
| 156 | 25946x | n_ -= n; | ||
| 157 | 25946x | return *this; | ||
| 158 | } | |||
| 159 | ||||
| 160 | /// Slice customization point for `tag_invoke`. | |||
| 161 | friend | |||
| 162 | void | |||
| 163 | 1335x | tag_invoke( | ||
| 164 | slice_tag const&, | |||
| 165 | mutable_buffer& b, | |||
| 166 | slice_how how, | |||
| 167 | std::size_t n) noexcept | |||
| 168 | { | |||
| 169 | 1335x | b.do_slice(how, n); | ||
| 170 | 1335x | } | ||
| 171 | ||||
| 172 | private: | |||
| 173 | 1335x | void do_slice( | ||
| 174 | slice_how how, std::size_t n) noexcept | |||
| 175 | { | |||
| 176 |
2/3✓ Branch 0 taken 659 times.
✓ Branch 1 taken 676 times.
✗ Branch 2 not taken.
|
1335x | switch(how) | |
| 177 | { | |||
| 178 | 659x | case slice_how::remove_prefix: | ||
| 179 | 659x | *this += n; | ||
| 180 | 659x | return; | ||
| 181 | ||||
| 182 | 676x | case slice_how::keep_prefix: | ||
| 183 |
2/2✓ Branch 0 taken 584 times.
✓ Branch 1 taken 92 times.
|
676x | if( n < n_) | |
| 184 | 584x | n_ = n; | ||
| 185 | 676x | return; | ||
| 186 | } | |||
| 187 | } | |||
| 188 | }; | |||
| 189 | ||||
| 190 | //------------------------------------------------ | |||
| 191 | ||||
| 192 | /** A reference to a contiguous region of read-only memory. | |||
| 193 | ||||
| 194 | Represents a pointer and size pair for a non-modifiable byte range. | |||
| 195 | Does not own the memory. Satisfies `ConstBufferSequence` (as a | |||
| 196 | single-element sequence). Implicitly constructible from | |||
| 197 | `mutable_buffer`. | |||
| 198 | ||||
| 199 | @see mutable_buffer, ConstBufferSequence | |||
| 200 | */ | |||
| 201 | class const_buffer | |||
| 202 | : public detail::basic_buffer<unsigned char const> | |||
| 203 | { | |||
| 204 | public: | |||
| 205 | /// Construct an empty buffer. | |||
| 206 | 611x | const_buffer() = default; | ||
| 207 | ||||
| 208 | /// Copy constructor. | |||
| 209 | const_buffer(const_buffer const&) = default; | |||
| 210 | ||||
| 211 | /// Copy assignment. | |||
| 212 | const_buffer& operator=( | |||
| 213 | const_buffer const& other) = default; | |||
| 214 | ||||
| 215 | /// Construct from pointer and size. | |||
| 216 | 21791x | constexpr const_buffer( | ||
| 217 | void const* data, std::size_t size) noexcept | |||
| 218 | 21791x | : basic_buffer<unsigned char const>( | ||
| 219 | 21791x | static_cast<unsigned char const*>(data), size) | ||
| 220 | { | |||
| 221 | 21791x | } | ||
| 222 | ||||
| 223 | /// Construct from mutable_buffer. | |||
| 224 | 15442x | constexpr const_buffer( | ||
| 225 | mutable_buffer const& b) noexcept | |||
| 226 | 15442x | : basic_buffer<unsigned char const>( | ||
| 227 | 15442x | static_cast<unsigned char const*>(b.data()), b.size()) | ||
| 228 | { | |||
| 229 | 15442x | } | ||
| 230 | ||||
| 231 | /// Construct from Asio buffer types. | |||
| 232 | template<class ConstBuffer> | |||
| 233 | requires (std::same_as<ConstBuffer, asio::const_buffer> || | |||
| 234 | std::same_as<ConstBuffer, asio::mutable_buffer>) | |||
| 235 | constexpr const_buffer( | |||
| 236 | ConstBuffer const& b) noexcept | |||
| 237 | : basic_buffer<unsigned char const>( | |||
| 238 | static_cast<unsigned char const*>( | |||
| 239 | b.data()), b.size()) | |||
| 240 | { | |||
| 241 | } | |||
| 242 | ||||
| 243 | /// Return a pointer to the memory region. | |||
| 244 | 63200x | constexpr void const* data() const noexcept | ||
| 245 | { | |||
| 246 | 63200x | return p_; | ||
| 247 | } | |||
| 248 | ||||
| 249 | /// Return the size in bytes. | |||
| 250 | 121334x | constexpr std::size_t size() const noexcept | ||
| 251 | { | |||
| 252 | 121334x | return n_; | ||
| 253 | } | |||
| 254 | ||||
| 255 | /** Advance the buffer start, shrinking the region. | |||
| 256 | ||||
| 257 | @param n Bytes to skip. Clamped to `size()`. | |||
| 258 | */ | |||
| 259 | const_buffer& | |||
| 260 | 26601x | operator+=(std::size_t n) noexcept | ||
| 261 | { | |||
| 262 |
2/2✓ Branch 0 taken 16 times.
✓ Branch 1 taken 26585 times.
|
26601x | if( n > n_) | |
| 263 | 16x | n = n_; | ||
| 264 | 26601x | p_ += n; | ||
| 265 | 26601x | n_ -= n; | ||
| 266 | 26601x | return *this; | ||
| 267 | } | |||
| 268 | ||||
| 269 | /// Slice customization point for `tag_invoke`. | |||
| 270 | friend | |||
| 271 | void | |||
| 272 | 2640x | tag_invoke( | ||
| 273 | slice_tag const&, | |||
| 274 | const_buffer& b, | |||
| 275 | slice_how how, | |||
| 276 | std::size_t n) noexcept | |||
| 277 | { | |||
| 278 | 2640x | b.do_slice(how, n); | ||
| 279 | 2640x | } | ||
| 280 | ||||
| 281 | private: | |||
| 282 | 2640x | void do_slice( | ||
| 283 | slice_how how, std::size_t n) noexcept | |||
| 284 | { | |||
| 285 |
2/3✓ Branch 0 taken 1313 times.
✓ Branch 1 taken 1327 times.
✗ Branch 2 not taken.
|
2640x | switch(how) | |
| 286 | { | |||
| 287 | 1313x | case slice_how::remove_prefix: | ||
| 288 | 1313x | *this += n; | ||
| 289 | 1313x | return; | ||
| 290 | ||||
| 291 | 1327x | case slice_how::keep_prefix: | ||
| 292 |
2/2✓ Branch 0 taken 1238 times.
✓ Branch 1 taken 89 times.
|
1327x | if( n < n_) | |
| 293 | 1238x | n_ = n; | ||
| 294 | 1327x | return; | ||
| 295 | } | |||
| 296 | } | |||
| 297 | }; | |||
| 298 | ||||
| 299 | //------------------------------------------------ | |||
| 300 | ||||
| 301 | /** Concept for sequences of read-only buffer regions. | |||
| 302 | ||||
| 303 | A type satisfies `ConstBufferSequence` if it represents one or more | |||
| 304 | contiguous memory regions that can be read. This includes single | |||
| 305 | buffers (convertible to `const_buffer`) and ranges of buffers. | |||
| 306 | ||||
| 307 | @par Syntactic Requirements | |||
| 308 | @li Convertible to `const_buffer`, OR | |||
| 309 | @li A bidirectional range with value type convertible to `const_buffer` | |||
| 310 | ||||
| 311 | @see const_buffer, MutableBufferSequence | |||
| 312 | */ | |||
| 313 | template<typename T> | |||
| 314 | concept ConstBufferSequence = | |||
| 315 | std::is_convertible_v<T, const_buffer> || ( | |||
| 316 | std::ranges::bidirectional_range<T> && | |||
| 317 | std::is_convertible_v<std::ranges::range_value_t<T>, const_buffer>); | |||
| 318 | ||||
| 319 | /** Concept for sequences of writable buffer regions. | |||
| 320 | ||||
| 321 | A type satisfies `MutableBufferSequence` if it represents one or more | |||
| 322 | contiguous memory regions that can be written. This includes single | |||
| 323 | buffers (convertible to `mutable_buffer`) and ranges of buffers. | |||
| 324 | Every `MutableBufferSequence` also satisfies `ConstBufferSequence`. | |||
| 325 | ||||
| 326 | @par Syntactic Requirements | |||
| 327 | @li Convertible to `mutable_buffer`, OR | |||
| 328 | @li A bidirectional range with value type convertible to `mutable_buffer` | |||
| 329 | ||||
| 330 | @see mutable_buffer, ConstBufferSequence | |||
| 331 | */ | |||
| 332 | template<typename T> | |||
| 333 | concept MutableBufferSequence = | |||
| 334 | std::is_convertible_v<T, mutable_buffer> || ( | |||
| 335 | std::ranges::bidirectional_range<T> && | |||
| 336 | std::is_convertible_v<std::ranges::range_value_t<T>, mutable_buffer>); | |||
| 337 | ||||
| 338 | //------------------------------------------------------------------------------ | |||
| 339 | ||||
| 340 | /** Return an iterator to the first buffer in a sequence. | |||
| 341 | ||||
| 342 | Handles single buffers and ranges uniformly. For a single buffer, | |||
| 343 | returns a pointer to it (forming a one-element range). | |||
| 344 | */ | |||
| 345 | constexpr struct begin_mrdocs_workaround_t | |||
| 346 | { | |||
| 347 | template<std::convertible_to<const_buffer> ConvertibleToBuffer> | |||
| 348 | 19539x | auto operator()(ConvertibleToBuffer const& b) const noexcept -> ConvertibleToBuffer const* | ||
| 349 | { | |||
| 350 | 19539x | return std::addressof(b); | ||
| 351 | } | |||
| 352 | ||||
| 353 | template<ConstBufferSequence BS> | |||
| 354 | requires (!std::convertible_to<BS, const_buffer>) | |||
| 355 | 55944x | auto operator()(BS const& bs) const noexcept | ||
| 356 | { | |||
| 357 | 55944x | return std::ranges::begin(bs); | ||
| 358 | } | |||
| 359 | ||||
| 360 | template<ConstBufferSequence BS> | |||
| 361 | requires (!std::convertible_to<BS, const_buffer>) | |||
| 362 | 18574x | auto operator()(BS& bs) const noexcept | ||
| 363 | { | |||
| 364 | 18574x | return std::ranges::begin(bs); | ||
| 365 | } | |||
| 366 | } begin {}; | |||
| 367 | ||||
| 368 | /** Return an iterator past the last buffer in a sequence. | |||
| 369 | ||||
| 370 | Handles single buffers and ranges uniformly. For a single buffer, | |||
| 371 | returns a pointer one past it. | |||
| 372 | */ | |||
| 373 | constexpr struct end_mrdocs_workaround_t | |||
| 374 | { | |||
| 375 | template<std::convertible_to<const_buffer> ConvertibleToBuffer> | |||
| 376 | 19299x | auto operator()(ConvertibleToBuffer const& b) const noexcept -> ConvertibleToBuffer const* | ||
| 377 | { | |||
| 378 | 19299x | return std::addressof(b) + 1; | ||
| 379 | } | |||
| 380 | ||||
| 381 | template<ConstBufferSequence BS> | |||
| 382 | requires (!std::convertible_to<BS, const_buffer>) | |||
| 383 | 48415x | auto operator()(BS const& bs) const noexcept | ||
| 384 | { | |||
| 385 | 48415x | return std::ranges::end(bs); | ||
| 386 | } | |||
| 387 | ||||
| 388 | template<ConstBufferSequence BS> | |||
| 389 | requires (!std::convertible_to<BS, const_buffer>) | |||
| 390 | 18574x | auto operator()(BS& bs) const noexcept | ||
| 391 | { | |||
| 392 | 18574x | return std::ranges::end(bs); | ||
| 393 | } | |||
| 394 | } end {}; | |||
| 395 | ||||
| 396 | //------------------------------------------------------------------------------ | |||
| 397 | ||||
| 398 | template<ConstBufferSequence CB> | |||
| 399 | std::size_t | |||
| 400 | 13285x | tag_invoke( | ||
| 401 | size_tag const&, | |||
| 402 | CB const& bs) noexcept | |||
| 403 | { | |||
| 404 | 13285x | std::size_t n = 0; | ||
| 405 | 13285x | auto const e = end(bs); | ||
| 406 |
44/44unsigned long boost::capy::tag_invoke<boost::capy::const_buffer [3]>(boost::capy::size_tag const&, boost::capy::const_buffer const (&) [3]):
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 1 time.
unsigned long boost::capy::tag_invoke<boost::capy::const_buffer>(boost::capy::size_tag const&, boost::capy::const_buffer const&):
✓ Branch 1 taken 5001 times.
✓ Branch 2 taken 5001 times.
unsigned long boost::capy::tag_invoke<boost::capy::consuming_buffers<boost::capy::const_buffer> >(boost::capy::size_tag const&, boost::capy::consuming_buffers<boost::capy::const_buffer> const&):
✓ Branch 2 taken 38 times.
✓ Branch 3 taken 38 times.
unsigned long boost::capy::tag_invoke<boost::capy::consuming_buffers<boost::capy::mutable_buffer> >(boost::capy::size_tag const&, boost::capy::consuming_buffers<boost::capy::mutable_buffer> const&):
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 3 times.
unsigned long boost::capy::tag_invoke<boost::capy::consuming_buffers<std::array<boost::capy::const_buffer, 2ul> > >(boost::capy::size_tag const&, boost::capy::consuming_buffers<std::array<boost::capy::const_buffer, 2ul> > const&):
✓ Branch 2 taken 28 times.
✓ Branch 3 taken 14 times.
unsigned long boost::capy::tag_invoke<boost::capy::consuming_buffers<std::array<boost::capy::mutable_buffer, 2ul> > >(boost::capy::size_tag const&, boost::capy::consuming_buffers<std::array<boost::capy::mutable_buffer, 2ul> > const&):
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 1 time.
unsigned long boost::capy::tag_invoke<boost::capy::mutable_buffer [3]>(boost::capy::size_tag const&, boost::capy::mutable_buffer const (&) [3]):
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 1 time.
unsigned long boost::capy::tag_invoke<boost::capy::mutable_buffer>(boost::capy::size_tag const&, boost::capy::mutable_buffer const&):
✓ Branch 1 taken 738 times.
✓ Branch 2 taken 738 times.
unsigned long boost::capy::tag_invoke<boost::capy::slice_of<std::array<boost::capy::const_buffer, 3ul> > >(boost::capy::size_tag const&, boost::capy::slice_of<std::array<boost::capy::const_buffer, 3ul> > const&):
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 14 times.
unsigned long boost::capy::tag_invoke<boost::capy::slice_of<std::span<boost::capy::const_buffer const, 18446744073709551615ul> > >(boost::capy::size_tag const&, boost::capy::slice_of<std::span<boost::capy::const_buffer const, 18446744073709551615ul> > const&):
✓ Branch 2 taken 222 times.
✓ Branch 3 taken 110 times.
unsigned long boost::capy::tag_invoke<boost::capy::slice_of<std::span<boost::capy::mutable_buffer const, 18446744073709551615ul> > >(boost::capy::size_tag const&, boost::capy::slice_of<std::span<boost::capy::mutable_buffer const, 18446744073709551615ul> > const&):
✓ Branch 2 taken 222 times.
✓ Branch 3 taken 110 times.
unsigned long boost::capy::tag_invoke<boost::capy::slice_of<std::vector<boost::capy::const_buffer, std::allocator<boost::capy::const_buffer> > > >(boost::capy::size_tag const&, boost::capy::slice_of<std::vector<boost::capy::const_buffer, std::allocator<boost::capy::const_buffer> > > const&):
✓ Branch 2 taken 1728 times.
✓ Branch 3 taken 986 times.
unsigned long boost::capy::tag_invoke<std::array<boost::capy::const_buffer, 2ul> >(boost::capy::size_tag const&, std::array<boost::capy::const_buffer, 2ul> const&):
✓ Branch 1 taken 5816 times.
✓ Branch 2 taken 2908 times.
unsigned long boost::capy::tag_invoke<std::array<boost::capy::const_buffer, 3ul> >(boost::capy::size_tag const&, std::array<boost::capy::const_buffer, 3ul> const&):
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 2 times.
unsigned long boost::capy::tag_invoke<std::array<boost::capy::mutable_buffer, 2ul> >(boost::capy::size_tag const&, std::array<boost::capy::mutable_buffer, 2ul> const&):
✓ Branch 1 taken 5676 times.
✓ Branch 2 taken 2838 times.
unsigned long boost::capy::tag_invoke<std::array<boost::capy::mutable_buffer, 3ul> >(boost::capy::size_tag const&, std::array<boost::capy::mutable_buffer, 3ul> const&):
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 1 time.
unsigned long boost::capy::tag_invoke<std::span<boost::capy::const_buffer const, 18446744073709551615ul> >(boost::capy::size_tag const&, std::span<boost::capy::const_buffer const, 18446744073709551615ul> const&):
✓ Branch 2 taken 357 times.
✓ Branch 3 taken 131 times.
unsigned long boost::capy::tag_invoke<std::span<boost::capy::const_buffer, 18446744073709551615ul> >(boost::capy::size_tag const&, std::span<boost::capy::const_buffer, 18446744073709551615ul> const&):
✓ Branch 2 taken 222 times.
✓ Branch 3 taken 222 times.
unsigned long boost::capy::tag_invoke<std::span<boost::capy::const_buffer, 3ul> >(boost::capy::size_tag const&, std::span<boost::capy::const_buffer, 3ul> const&):
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 1 time.
unsigned long boost::capy::tag_invoke<std::span<boost::capy::mutable_buffer const, 18446744073709551615ul> >(boost::capy::size_tag const&, std::span<boost::capy::mutable_buffer const, 18446744073709551615ul> const&):
✓ Branch 2 taken 301 times.
✓ Branch 3 taken 163 times.
unsigned long boost::capy::tag_invoke<std::span<boost::capy::mutable_buffer, 3ul> >(boost::capy::size_tag const&, std::span<boost::capy::mutable_buffer, 3ul> const&):
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 1 time.
unsigned long boost::capy::tag_invoke<std::vector<boost::capy::const_buffer, std::allocator<boost::capy::const_buffer> > >(boost::capy::size_tag const&, std::vector<boost::capy::const_buffer, std::allocator<boost::capy::const_buffer> > const&):
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 1 time.
|
33687x | for(auto it = begin(bs); it != e; ++it) | |
| 407 | 20402x | n += const_buffer(*it).size(); | ||
| 408 | 13285x | return n; | ||
| 409 | } | |||
| 410 | ||||
| 411 | //------------------------------------------------------------------------------ | |||
| 412 | ||||
| 413 | /** Return the total byte count across all buffers in a sequence. | |||
| 414 | ||||
| 415 | Sums the `size()` of each buffer in the sequence. This differs | |||
| 416 | from `buffer_length` which counts the number of buffer elements. | |||
| 417 | ||||
| 418 | @par Example | |||
| 419 | @code | |||
| 420 | std::array<mutable_buffer, 2> bufs = { ... }; | |||
| 421 | std::size_t total = buffer_size( bufs ); // sum of both sizes | |||
| 422 | @endcode | |||
| 423 | */ | |||
| 424 | constexpr struct buffer_size_mrdocs_workaround_t | |||
| 425 | { | |||
| 426 | template<ConstBufferSequence CB> | |||
| 427 | 18784x | constexpr std::size_t operator()( | ||
| 428 | CB const& bs) const noexcept | |||
| 429 | { | |||
| 430 | 18784x | return tag_invoke(size_tag{}, bs); | ||
| 431 | } | |||
| 432 | } buffer_size {}; | |||
| 433 | ||||
| 434 | /** Check if a buffer sequence contains no data. | |||
| 435 | ||||
| 436 | @return `true` if all buffers have size zero or the sequence | |||
| 437 | is empty. | |||
| 438 | */ | |||
| 439 | constexpr struct buffer_empty_mrdocs_workaround_t | |||
| 440 | { | |||
| 441 | template<ConstBufferSequence CB> | |||
| 442 | 3208x | constexpr bool operator()( | ||
| 443 | CB const& bs) const noexcept | |||
| 444 | { | |||
| 445 | 3208x | auto it = begin(bs); | ||
| 446 | 3208x | auto const end_ = end(bs); | ||
| 447 |
6/8bool boost::capy::buffer_empty_mrdocs_workaround_t::operator()<boost::capy::mutable_buffer>(boost::capy::mutable_buffer const&) const:
✓ Branch 0 taken 377 times.
✓ Branch 1 taken 2 times.
bool boost::capy::buffer_empty_mrdocs_workaround_t::operator()<std::span<boost::capy::const_buffer const, 18446744073709551615ul> >(std::span<boost::capy::const_buffer const, 18446744073709551615ul> const&) const:
✓ Branch 1 taken 101 times.
✗ Branch 2 not taken.
bool boost::capy::buffer_empty_mrdocs_workaround_t::operator()<std::span<boost::capy::const_buffer, 18446744073709551615ul> >(std::span<boost::capy::const_buffer, 18446744073709551615ul> const&) const:
✓ Branch 1 taken 148 times.
✗ Branch 2 not taken.
bool boost::capy::buffer_empty_mrdocs_workaround_t::operator()<std::span<boost::capy::mutable_buffer const, 18446744073709551615ul> >(std::span<boost::capy::mutable_buffer const, 18446744073709551615ul> const&) const:
✓ Branch 1 taken 788 times.
✓ Branch 2 taken 3 times.
|
3233x | while(it != end_) | |
| 448 | { | |||
| 449 | 3221x | const_buffer b(*it++); | ||
| 450 |
5/8bool boost::capy::buffer_empty_mrdocs_workaround_t::operator()<boost::capy::mutable_buffer>(boost::capy::mutable_buffer const&) const:
✓ Branch 1 taken 375 times.
✓ Branch 2 taken 2 times.
bool boost::capy::buffer_empty_mrdocs_workaround_t::operator()<std::span<boost::capy::const_buffer const, 18446744073709551615ul> >(std::span<boost::capy::const_buffer const, 18446744073709551615ul> const&) const:
✓ Branch 1 taken 101 times.
✗ Branch 2 not taken.
bool boost::capy::buffer_empty_mrdocs_workaround_t::operator()<std::span<boost::capy::const_buffer, 18446744073709551615ul> >(std::span<boost::capy::const_buffer, 18446744073709551615ul> const&) const:
✓ Branch 1 taken 148 times.
✗ Branch 2 not taken.
bool boost::capy::buffer_empty_mrdocs_workaround_t::operator()<std::span<boost::capy::mutable_buffer const, 18446744073709551615ul> >(std::span<boost::capy::mutable_buffer const, 18446744073709551615ul> const&) const:
✓ Branch 1 taken 788 times.
✗ Branch 2 not taken.
|
3221x | if(b.size() != 0) | |
| 451 | 3196x | return false; | ||
| 452 | } | |||
| 453 | 12x | return true; | ||
| 454 | } | |||
| 455 | } buffer_empty {}; | |||
| 456 | ||||
| 457 | //----------------------------------------------- | |||
| 458 | ||||
| 459 | namespace detail { | |||
| 460 | ||||
| 461 | template<class It> | |||
| 462 | auto | |||
| 463 | 240x | length_impl(It first, It last, int) | ||
| 464 | -> decltype(static_cast<std::size_t>(last - first)) | |||
| 465 | { | |||
| 466 | 240x | return static_cast<std::size_t>(last - first); | ||
| 467 | } | |||
| 468 | ||||
| 469 | template<class It> | |||
| 470 | std::size_t | |||
| 471 | length_impl(It first, It last, long) | |||
| 472 | { | |||
| 473 | std::size_t n = 0; | |||
| 474 | while(first != last) | |||
| 475 | { | |||
| 476 | ++first; | |||
| 477 | ++n; | |||
| 478 | } | |||
| 479 | return n; | |||
| 480 | } | |||
| 481 | ||||
| 482 | } // detail | |||
| 483 | ||||
| 484 | /** Return the number of buffer elements in a sequence. | |||
| 485 | ||||
| 486 | Counts the number of individual buffer objects, not bytes. | |||
| 487 | For a single buffer, returns 1. For a range, returns the | |||
| 488 | distance from `begin` to `end`. | |||
| 489 | ||||
| 490 | @see buffer_size | |||
| 491 | */ | |||
| 492 | template<ConstBufferSequence CB> | |||
| 493 | std::size_t | |||
| 494 | 240x | buffer_length(CB const& bs) | ||
| 495 | { | |||
| 496 | 240x | return detail::length_impl( | ||
| 497 | 240x | begin(bs), end(bs), 0); | ||
| 498 | } | |||
| 499 | ||||
| 500 | /// Alias for `mutable_buffer` or `const_buffer` based on sequence type. | |||
| 501 | template<typename BS> | |||
| 502 | using buffer_type = std::conditional_t< | |||
| 503 | MutableBufferSequence<BS>, | |||
| 504 | mutable_buffer, const_buffer>; | |||
| 505 | ||||
| 506 | } // capy | |||
| 507 | } // boost | |||
| 508 | ||||
| 509 | #endif | |||
| 510 |