100.00% Lines (4/4)
100.00% Functions (2/2)
| TLA | Baseline | Branch | ||||||
|---|---|---|---|---|---|---|---|---|
| Line | Hits | Code | Line | Hits | Code | |||
| 1 | // | 1 | // | |||||
| 2 | // Copyright (c) 2025 Vinnie Falco (vinnie.falco@gmail.com) | 2 | // Copyright (c) 2025 Vinnie Falco (vinnie.falco@gmail.com) | |||||
| 3 | // | 3 | // | |||||
| 4 | // Distributed under the Boost Software License, Version 1.0. (See accompanying | 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) | 5 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | |||||
| 6 | // | 6 | // | |||||
| 7 | // Official repository: https://github.com/cppalliance/capy | 7 | // Official repository: https://github.com/cppalliance/capy | |||||
| 8 | // | 8 | // | |||||
| 9 | 9 | |||||||
| 10 | #ifndef BOOST_CAPY_DETAIL_RUN_HPP | 10 | #ifndef BOOST_CAPY_DETAIL_RUN_HPP | |||||
| 11 | #define BOOST_CAPY_DETAIL_RUN_HPP | 11 | #define BOOST_CAPY_DETAIL_RUN_HPP | |||||
| 12 | 12 | |||||||
| 13 | #include <boost/capy/detail/config.hpp> | 13 | #include <boost/capy/detail/config.hpp> | |||||
| 14 | #include <boost/capy/detail/frame_memory_resource.hpp> | 14 | #include <boost/capy/detail/frame_memory_resource.hpp> | |||||
| 15 | 15 | |||||||
| 16 | #include <cstddef> | 16 | #include <cstddef> | |||||
| 17 | #include <memory_resource> | 17 | #include <memory_resource> | |||||
| 18 | 18 | |||||||
| 19 | namespace boost { | 19 | namespace boost { | |||||
| 20 | namespace capy { | 20 | namespace capy { | |||||
| 21 | namespace detail { | 21 | namespace detail { | |||||
| 22 | 22 | |||||||
| 23 | /// Concept for standard Allocator types. | 23 | /// Concept for standard Allocator types. | |||||
| 24 | template<class A> | 24 | template<class A> | |||||
| 25 | concept Allocator = requires(A a, std::size_t n) { | 25 | concept Allocator = requires(A a, std::size_t n) { | |||||
| 26 | typename A::value_type; | 26 | typename A::value_type; | |||||
| 27 | { a.allocate(n) } -> std::same_as<typename A::value_type*>; | 27 | { a.allocate(n) } -> std::same_as<typename A::value_type*>; | |||||
| 28 | }; | 28 | }; | |||||
| 29 | 29 | |||||||
| 30 | /// Specialization for memory_resource* - stores pointer directly. | 30 | /// Specialization for memory_resource* - stores pointer directly. | |||||
| 31 | template<> | 31 | template<> | |||||
| 32 | class frame_memory_resource<std::pmr::memory_resource*> | 32 | class frame_memory_resource<std::pmr::memory_resource*> | |||||
| 33 | { | 33 | { | |||||
| 34 | std::pmr::memory_resource* mr_; | 34 | std::pmr::memory_resource* mr_; | |||||
| 35 | 35 | |||||||
| 36 | public: | 36 | public: | |||||
| HITCBC | 37 | 5 | explicit frame_memory_resource(std::pmr::memory_resource* mr) noexcept | 37 | 5 | explicit frame_memory_resource(std::pmr::memory_resource* mr) noexcept | ||
| HITCBC | 38 | 5 | : mr_(mr) | 38 | 5 | : mr_(mr) | ||
| 39 | { | 39 | { | |||||
| HITCBC | 40 | 5 | } | 40 | 5 | } | ||
| 41 | 41 | |||||||
| HITCBC | 42 | 5 | std::pmr::memory_resource* get() noexcept { return mr_; } | 42 | 5 | std::pmr::memory_resource* get() noexcept { return mr_; } | ||
| 43 | }; | 43 | }; | |||||
| 44 | 44 | |||||||
| 45 | /// Specialization for void - no allocator (empty). | 45 | /// Specialization for void - no allocator (empty). | |||||
| 46 | template<> | 46 | template<> | |||||
| 47 | class frame_memory_resource<void> | 47 | class frame_memory_resource<void> | |||||
| 48 | { | 48 | { | |||||
| 49 | public: | 49 | public: | |||||
| 50 | frame_memory_resource() = default; | 50 | frame_memory_resource() = default; | |||||
| 51 | 51 | |||||||
| 52 | std::pmr::memory_resource* get() noexcept { return nullptr; } | 52 | std::pmr::memory_resource* get() noexcept { return nullptr; } | |||||
| 53 | }; | 53 | }; | |||||
| 54 | 54 | |||||||
| 55 | } // namespace detail | 55 | } // namespace detail | |||||
| 56 | } // namespace capy | 56 | } // namespace capy | |||||
| 57 | } // namespace boost | 57 | } // namespace boost | |||||
| 58 | 58 | |||||||
| 59 | #endif | 59 | #endif | |||||