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:21:58 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 <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           21 :     shared_resource_impl(
      49              :         Args&&... args)
      50           21 :         : t(std::forward<Args>(args)...)
      51              :     {
      52           21 :     }
      53              : 
      54              :     void*
      55           49 :     do_allocate(
      56              :         std::size_t n,
      57              :         std::size_t align) override
      58              :     {
      59           49 :         return t.allocate(n, align);
      60              :     }
      61              : 
      62              :     void
      63           49 :     do_deallocate(
      64              :         void* p,
      65              :         std::size_t n,
      66              :         std::size_t align) override
      67              :     {
      68           49 :         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
        

Generated by: LCOV version 2.1