2 // Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com)
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)
7 // Official repository: https://github.com/boostorg/json
10 #ifndef BOOST_JSON_IMPL_NULL_RESOURCE_IPP
11 #define BOOST_JSON_IMPL_NULL_RESOURCE_IPP
13 #include <boost/json/null_resource.hpp>
14 #include <boost/json/detail/except.hpp>
20 /** A resource which always fails.
22 This memory resource always throws the exception
23 `std::bad_alloc` in calls to `allocate`.
25 class null_resource final
26 : public memory_resource
29 /// Copy constructor (deleted)
31 null_resource const&) = delete;
33 /// Copy assignment (deleted)
34 null_resource& operator=(
35 null_resource const&) = delete;
39 This destroys the resource.
44 @part Exception Safety
47 ~null_resource() noexcept = default;
51 This constructs the resource.
60 null_resource() noexcept = default;
68 detail::throw_bad_alloc(
69 BOOST_CURRENT_LOCATION);
83 memory_resource const& mr
84 ) const noexcept override
93 get_null_resource() noexcept
95 static detail::null_resource mr;