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

This is the documentation for an old version of Boost. Click here to view this page for the latest version.


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


Defined in header <boost/json/memory_resource.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 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 {

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

memory_resource, storage_ptr

Convenience header <boost/json.hpp>