GCC Code Coverage Report


Directory: libs/json/include/boost/json/
File: detail/shared_resource.hpp
Date: 2025-12-23 17:22:01
Exec Total Coverage
Lines: 9 9 100.0%
Functions: 8 13 61.5%
Branches: 0 1 0.0%

Line Branch Exec Source
1 //
2 // Copyright (c) 2019 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/boostorg/json
8 //
9
10 #ifndef BOOST_JSON_DETAIL_SHARED_RESOURCE_HPP
11 #define BOOST_JSON_DETAIL_SHARED_RESOURCE_HPP
12
13 #include <boost/container/pmr/memory_resource.hpp>
14 #include <boost/json/memory_resource.hpp>
15 #include <atomic>
16 #include <utility>
17
18 namespace boost {
19 namespace json {
20 namespace detail {
21
22 #ifdef _MSC_VER
23 #pragma warning(push)
24 #pragma warning(disable: 4275) // non dll-interface class used as base for dll-interface class
25 #endif
26
27 struct BOOST_SYMBOL_VISIBLE
28 shared_resource
29 : container::pmr::memory_resource
30 {
31 BOOST_JSON_DECL
32 shared_resource();
33
34 BOOST_JSON_DECL
35 ~shared_resource();
36
37 std::atomic<std::size_t> refs{ 1 };
38 };
39
40 template<class T>
41 class shared_resource_impl final
42 : public shared_resource
43 {
44 T t;
45
46 public:
47 template<class... Args>
48 35 shared_resource_impl(
49 Args&&... args)
50
0/1
✗ Branch 2 not taken.
35 : t(std::forward<Args>(args)...)
51 {
52 35 }
53
54 void*
55 71 do_allocate(
56 std::size_t n,
57 std::size_t align) override
58 {
59 71 return t.allocate(n, align);
60 }
61
62 void
63 71 do_deallocate(
64 void* p,
65 std::size_t n,
66 std::size_t align) override
67 {
68 71 return t.deallocate(p, n, align);
69 }
70
71 bool
72 12 do_is_equal(
73 memory_resource const&) const noexcept override
74 {
75 // VFALCO Is always false ok?
76 12 return false;
77 }
78 };
79
80 #ifdef _MSC_VER
81 #pragma warning(pop)
82 #endif
83
84 } // detail
85 } // namespace json
86 } // namespace boost
87
88 #endif
89