LCOV - code coverage report
Current view: top level - json/detail - shared_resource.hpp (source / functions) Coverage Total Hit
Test: coverage_filtered.info Lines: 100.0 % 9 9
Test Date: 2025-12-23 17:20:51 Functions: 56.2 % 16 9

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

Generated by: LCOV version 2.1