...one 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>
template< class T> struct is_deallocate_trivial;
Name |
Description |
---|---|
A bool equal to true if calls to |
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.
storage_ptr
,
boost::container::pmr::memory_resource
Convenience header <boost/json.hpp>