Boost C++ Libraries of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards



Return true if a memory resource's deallocate function has no effect.


Defined in header <boost/json/is_deallocate_trivial.hpp>

    class T>
struct is_deallocate_trivial
Static Members




A bool equal to true if calls to T::do_deallocate have no effect.


This metafunction may be specialized to indicate to the library that calls to the deallocate function of a boost::container::pmr::memory_resource have no effect. The implementation will elide such calls when it is safe to do so. By default, the implementation assumes that all memory resources require a call to deallocate for each memory region obtained by calling allocate.


This example specializes the metafuction for my_resource, to indicate that calls to deallocate have no effect:

// Forward-declaration for a user-defined memory resource
struct my_resource;

// It is necessary to specialize the template from
// inside the namespace in which it is declared:

namespace boost {
namespace json {

template <>
struct is_deallocate_trivial< my_resource >
    static constexpr bool value = true ;

} // namespace json
} // namespace boost

It is usually not necessary for users to check this trait. Instead, they can call storage_ptr::is_deallocate_trivial to determine if the pointed-to memory resource has a trivial deallocate function.

See Also

storage_ptr, boost::container::pmr::memory_resource.

Convenience header <boost/json.hpp>