File indexing completed on 2025-01-18 09:39:01
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef BOOST_JSON_IMPL_NULL_RESOURCE_IPP
0011 #define BOOST_JSON_IMPL_NULL_RESOURCE_IPP
0012
0013 #include <boost/json/null_resource.hpp>
0014 #include <boost/throw_exception.hpp>
0015
0016 namespace boost {
0017 namespace json {
0018
0019 namespace detail {
0020
0021
0022
0023
0024
0025
0026 class null_resource final
0027 : public memory_resource
0028 {
0029 public:
0030
0031 null_resource(
0032 null_resource const&) = delete;
0033
0034
0035 null_resource& operator=(
0036 null_resource const&) = delete;
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049 null_resource() noexcept = default;
0050
0051 protected:
0052 void*
0053 do_allocate(
0054 std::size_t,
0055 std::size_t) override
0056 {
0057 throw_exception( std::bad_alloc(), BOOST_CURRENT_LOCATION );
0058 }
0059
0060 void
0061 do_deallocate(
0062 void*,
0063 std::size_t,
0064 std::size_t) override
0065 {
0066
0067 }
0068
0069 bool
0070 do_is_equal(
0071 memory_resource const& mr
0072 ) const noexcept override
0073 {
0074 return this == &mr;
0075 }
0076 };
0077
0078 }
0079
0080 memory_resource*
0081 get_null_resource() noexcept
0082 {
0083 static detail::null_resource mr;
0084 return &mr;
0085 }
0086
0087 }
0088 }
0089
0090 #endif