LCOV - code coverage report
Current view: top level - src/immer/heap - cpp_heap.hpp (source / functions) Hit Total Coverage
Test: total_coverage.info Lines: 4 4 100.0 %
Date: 2025-02-23 09:33:43 Functions: 0 0 -

          Line data    Source code
       1             : //
       2             : // immer: immutable data structures for C++
       3             : // Copyright (C) 2016, 2017, 2018 Juan Pedro Bolivar Puente
       4             : //
       5             : // This software is distributed under the Boost Software License, Version 1.0.
       6             : // See accompanying file LICENSE or copy at http://boost.org/LICENSE_1_0.txt
       7             : //
       8             : 
       9             : #pragma once
      10             : 
      11             : #include <cstddef>
      12             : #include <memory>
      13             : 
      14             : namespace immer {
      15             : 
      16             : /*!
      17             :  * A heap that uses `operator new` and `operator delete`.
      18             :  */
      19             : struct cpp_heap
      20             : {
      21             :     /*!
      22             :      * Returns a pointer to a memory region of size `size`, if the
      23             :      * allocation was successful, and throws otherwise.
      24             :      */
      25             :     template <typename... Tags>
      26       66954 :     static void* allocate(std::size_t size, Tags...)
      27             :     {
      28       66954 :         return ::operator new(size);
      29             :     }
      30             : 
      31             :     /*!
      32             :      * Releases a memory region `data` that was previously returned by
      33             :      * `allocate`.  One must not use nor deallocate again a memory
      34             :      * region that once it has been deallocated.
      35             :      */
      36       65790 :     static void deallocate(std::size_t size, void* data)
      37             :     {
      38       65790 :         ::operator delete(data);
      39             :     }
      40             : };
      41             : 
      42             : } // namespace immer

Generated by: LCOV version 1.14