is_deallocate_trivial
Return true if a memory resource’s deallocate function has no effect.
Synopsis
Defined in header <boost/json/is_deallocate_trivial.hpp>.
template<
class T>
struct is_deallocate_trivial;
Static Members
Name | Description |
---|---|
A bool equal to true if calls to |
Description
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
.
Example
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
Convenience header <boost/json.hpp>.