detail/impl/default_resource.ipp
87.5% Lines (7/8)
75.0% Functions (3/4)
-% Branches (0/0)
detail/impl/default_resource.ipp
| Line | Hits | 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_IMPL_DEFAULT_RESOURCE_IPP | |
| 11 | #define BOOST_JSON_DETAIL_IMPL_DEFAULT_RESOURCE_IPP | |
| 12 | ||
| 13 | #include <boost/json/detail/default_resource.hpp> | |
| 14 | ||
| 15 | namespace boost { | |
| 16 | namespace json { | |
| 17 | namespace detail { | |
| 18 | ||
| 19 | #ifndef BOOST_JSON_WEAK_CONSTINIT | |
| 20 | # ifndef BOOST_JSON_NO_DESTROY | |
| 21 | BOOST_JSON_REQUIRE_CONST_INIT | |
| 22 | default_resource::holder | |
| 23 | default_resource::instance_; | |
| 24 | # else | |
| 25 | BOOST_JSON_REQUIRE_CONST_INIT | |
| 26 | default_resource | |
| 27 | default_resource::instance_; | |
| 28 | # endif | |
| 29 | #endif | |
| 30 | ||
| 31 | // this is here so that ~memory_resource | |
| 32 | // is emitted in the library instead of | |
| 33 | // the user's TU. | |
| 34 | ✗ | default_resource:: |
| 35 | ~default_resource() = default; | |
| 36 | ||
| 37 | void* | |
| 38 | 264138 | default_resource:: |
| 39 | do_allocate( | |
| 40 | std::size_t n, | |
| 41 | std::size_t) | |
| 42 | { | |
| 43 | 264138 | return ::operator new(n); |
| 44 | } | |
| 45 | ||
| 46 | void | |
| 47 | 264138 | default_resource:: |
| 48 | do_deallocate( | |
| 49 | void* p, | |
| 50 | std::size_t, | |
| 51 | std::size_t) | |
| 52 | { | |
| 53 | 264138 | ::operator delete(p); |
| 54 | 264138 | } |
| 55 | ||
| 56 | bool | |
| 57 | 23 | default_resource:: |
| 58 | do_is_equal( | |
| 59 | memory_resource const& mr) const noexcept | |
| 60 | { | |
| 61 | 23 | return this == &mr; |
| 62 | } | |
| 63 | ||
| 64 | } // detail | |
| 65 | } // namespace json | |
| 66 | } // namespace boost | |
| 67 | ||
| 68 | #endif | |
| 69 |