100.00% Lines (10/10)
100.00% Functions (2/2)
| TLA | Baseline | Branch | ||||||
|---|---|---|---|---|---|---|---|---|
| Line | Hits | Code | Line | Hits | Code | |||
| 1 | // | 1 | // | |||||
| 2 | // Copyright (c) 2023 Vinnie Falco (vinnie.falco@gmail.com) | 2 | // Copyright (c) 2023 Vinnie Falco (vinnie.falco@gmail.com) | |||||
| 3 | // Copyright (c) 2026 Steve Gerbino | 3 | // Copyright (c) 2026 Steve Gerbino | |||||
| 4 | // | 4 | // | |||||
| 5 | // Distributed under the Boost Software License, Version 1.0. (See accompanying | 5 | // Distributed under the Boost Software License, Version 1.0. (See accompanying | |||||
| 6 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | 6 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | |||||
| 7 | // | 7 | // | |||||
| 8 | // Official repository: https://github.com/cppalliance/capy | 8 | // Official repository: https://github.com/cppalliance/capy | |||||
| 9 | // | 9 | // | |||||
| 10 | 10 | |||||||
| 11 | #ifndef BOOST_CAPY_BUFFERS_BUFFERS_FRONT_HPP | 11 | #ifndef BOOST_CAPY_BUFFERS_BUFFERS_FRONT_HPP | |||||
| 12 | #define BOOST_CAPY_BUFFERS_BUFFERS_FRONT_HPP | 12 | #define BOOST_CAPY_BUFFERS_BUFFERS_FRONT_HPP | |||||
| 13 | 13 | |||||||
| 14 | #include <boost/capy/detail/config.hpp> | 14 | #include <boost/capy/detail/config.hpp> | |||||
| 15 | #include <boost/capy/buffers.hpp> | 15 | #include <boost/capy/buffers.hpp> | |||||
| 16 | 16 | |||||||
| 17 | namespace boost { | 17 | namespace boost { | |||||
| 18 | namespace capy { | 18 | namespace capy { | |||||
| 19 | 19 | |||||||
| 20 | // MrDocs 0.8.0 flags this object as `buffers_front: variable is | 20 | // MrDocs 0.8.0 flags this object as `buffers_front: variable is | |||||
| 21 | // undocumented`, as it does the other five buffer CPOs | 21 | // undocumented`, as it does the other five buffer CPOs | |||||
| 22 | // (buffer_sequence_begin, buffer_sequence_end, buffer_size, buffers_empty, | 22 | // (buffer_sequence_begin, buffer_sequence_end, buffer_size, buffers_empty, | |||||
| 23 | // buffer_copy). The finding is grandfathered in doc/lint/baseline.json. | 23 | // buffer_copy). The finding is grandfathered in doc/lint/baseline.json. | |||||
| 24 | // Silencing it buys nothing: on the synthesised overload page MrDocs renders | 24 | // Silencing it buys nothing: on the synthesised overload page MrDocs renders | |||||
| 25 | // neither the record-level docstring below nor one attached to the variable, | 25 | // neither the record-level docstring below nor one attached to the variable, | |||||
| 26 | // so any docstring that clears the warning is invisible to readers -- a | 26 | // so any docstring that clears the warning is invisible to readers -- a | |||||
| 27 | // second, dead copy of this prose. Verified twice against the built site. | 27 | // second, dead copy of this prose. Verified twice against the built site. | |||||
| 28 | /** Return the first buffer in a sequence. | 28 | /** Return the first buffer in a sequence. | |||||
| 29 | 29 | |||||||
| 30 | @functionobject | 30 | @functionobject | |||||
| 31 | */ | 31 | */ | |||||
| 32 | constexpr struct | 32 | constexpr struct | |||||
| 33 | { | 33 | { | |||||
| 34 | /** Return the first mutable buffer, or an empty buffer. | 34 | /** Return the first mutable buffer, or an empty buffer. | |||||
| 35 | 35 | |||||||
| 36 | @param bs The buffer sequence to inspect. | 36 | @param bs The buffer sequence to inspect. | |||||
| 37 | 37 | |||||||
| 38 | @return The first buffer in `bs`, or an empty buffer if `bs` | 38 | @return The first buffer in `bs`, or an empty buffer if `bs` | |||||
| 39 | contains no buffers. | 39 | contains no buffers. | |||||
| 40 | */ | 40 | */ | |||||
| 41 | template<MutableBufferSequence MutableBufferSequence> | 41 | template<MutableBufferSequence MutableBufferSequence> | |||||
| 42 | mutable_buffer | 42 | mutable_buffer | |||||
| HITCBC | 43 | 5 | operator()( | 43 | 5 | operator()( | ||
| 44 | MutableBufferSequence const& bs) const noexcept | 44 | MutableBufferSequence const& bs) const noexcept | |||||
| 45 | { | 45 | { | |||||
| HITCBC | 46 | 5 | auto const it = buffer_sequence_begin(bs); | 46 | 5 | auto const it = buffer_sequence_begin(bs); | ||
| HITCBC | 47 | 5 | if(it != buffer_sequence_end(bs)) | 47 | 5 | if(it != buffer_sequence_end(bs)) | ||
| HITCBC | 48 | 4 | return *it; | 48 | 4 | return *it; | ||
| HITCBC | 49 | 1 | return {}; | 49 | 1 | return {}; | ||
| 50 | } | 50 | } | |||||
| 51 | 51 | |||||||
| 52 | /** Return the first const buffer, or an empty buffer. | 52 | /** Return the first const buffer, or an empty buffer. | |||||
| 53 | 53 | |||||||
| 54 | @param bs The buffer sequence to inspect. | 54 | @param bs The buffer sequence to inspect. | |||||
| 55 | 55 | |||||||
| 56 | @return The first buffer in `bs`, or an empty buffer if `bs` | 56 | @return The first buffer in `bs`, or an empty buffer if `bs` | |||||
| 57 | contains no buffers. | 57 | contains no buffers. | |||||
| 58 | */ | 58 | */ | |||||
| 59 | template<ConstBufferSequence ConstBufferSequence> | 59 | template<ConstBufferSequence ConstBufferSequence> | |||||
| 60 | const_buffer | 60 | const_buffer | |||||
| HITCBC | 61 | 5 | operator()( | 61 | 5 | operator()( | ||
| 62 | ConstBufferSequence const& bs) const noexcept | 62 | ConstBufferSequence const& bs) const noexcept | |||||
| 63 | { | 63 | { | |||||
| HITCBC | 64 | 5 | auto const it = buffer_sequence_begin(bs); | 64 | 5 | auto const it = buffer_sequence_begin(bs); | ||
| HITCBC | 65 | 5 | if(it != buffer_sequence_end(bs)) | 65 | 5 | if(it != buffer_sequence_end(bs)) | ||
| HITCBC | 66 | 4 | return *it; | 66 | 4 | return *it; | ||
| HITCBC | 67 | 1 | return {}; | 67 | 1 | return {}; | ||
| 68 | } | 68 | } | |||||
| 69 | } const buffers_front{}; | 69 | } const buffers_front{}; | |||||
| 70 | 70 | |||||||
| 71 | } // capy | 71 | } // capy | |||||
| 72 | } // boost | 72 | } // boost | |||||
| 73 | 73 | |||||||
| 74 | #endif | 74 | #endif | |||||