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 | #include <boost/buffers/mutable_buffer_pair.hpp> | ||
11 | |||
12 | namespace boost { | ||
13 | namespace buffers { | ||
14 | |||
15 | mutable_buffer_pair | ||
16 | 544 | mutable_buffer_pair:: | |
17 | prefix_impl( | ||
18 | std::size_t n) const noexcept | ||
19 | { | ||
20 | 544 | auto const it0 = begin(); | |
21 |
2/2✓ Branch 1 taken 272 times.
✓ Branch 2 taken 272 times.
|
544 | if(n <= it0->size()) |
22 | return { { | ||
23 | it0->data(), n }, | ||
24 | 272 | mutable_buffer{} }; | |
25 | 272 | n -= it0->size(); | |
26 | 272 | auto it1 = it0; | |
27 | 272 | ++it1; | |
28 |
2/2✓ Branch 1 taken 210 times.
✓ Branch 2 taken 62 times.
|
272 | if(n < it1->size()) |
29 | return { *it0, { | ||
30 | 210 | it1->data(), n } }; | |
31 | 62 | return *this; | |
32 | } | ||
33 | |||
34 | mutable_buffer_pair | ||
35 | 544 | mutable_buffer_pair:: | |
36 | suffix_impl( | ||
37 | std::size_t n) const noexcept | ||
38 | { | ||
39 | 544 | auto it0 = end(); | |
40 | 544 | --it0; | |
41 |
2/2✓ Branch 1 taken 272 times.
✓ Branch 2 taken 272 times.
|
544 | if(n <= it0->size()) |
42 | 272 | return { *it0 + ( | |
43 | 272 | it0->size() - n), | |
44 | 272 | mutable_buffer{} }; | |
45 | 272 | n -= it0->size(); | |
46 | 272 | auto it1 = it0; | |
47 | 272 | --it1; | |
48 |
2/2✓ Branch 1 taken 210 times.
✓ Branch 2 taken 62 times.
|
272 | if(n < it1->size()) |
49 | 210 | return { *it1 + ( | |
50 | 210 | it1->size() - n), *it0 }; | |
51 | 62 | return *this; | |
52 | } | ||
53 | |||
54 | } // buffers | ||
55 | } // boost | ||
56 |