123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- #ifndef BOOST_JSON_IMPL_NULL_RESOURCE_IPP
- #define BOOST_JSON_IMPL_NULL_RESOURCE_IPP
- #include <boost/json/null_resource.hpp>
- #include <boost/throw_exception.hpp>
- namespace boost {
- namespace json {
- namespace detail {
- class null_resource final
- : public container::pmr::memory_resource
- {
- public:
-
- null_resource(
- null_resource const&) = delete;
-
- null_resource& operator=(
- null_resource const&) = delete;
-
-
- null_resource() noexcept = default;
- protected:
- void*
- do_allocate(
- std::size_t,
- std::size_t) override
- {
- throw_exception( std::bad_alloc(), BOOST_CURRENT_LOCATION );
- }
- void
- do_deallocate(
- void*,
- std::size_t,
- std::size_t) override
- {
-
- }
- bool
- do_is_equal(
- memory_resource const& mr
- ) const noexcept override
- {
- return this == &mr;
- }
- };
- }
- container::pmr::memory_resource*
- get_null_resource() noexcept
- {
- static detail::null_resource mr;
- return &mr;
- }
- }
- }
- #endif
|