BDE 4.14.0 Production release
|
Typedefs | |
typedef bslma::DeleterHelper | bslma_DeleterHelper |
This alias is defined for backward compatibility. | |
Provide namespace for functions used to delete objects.
This component provides non-primitive procedures used to delete objects of parameterized TYPE
by first calling the destructor of the object, and then freeing the memory footprint of the object using a parameterized ALLOCATOR
(allocator or pool) provided as a second argument. The "raw" method (deleteObjectRaw
) should be used only if we are sure that the supplied object is not of a type that is a secondary base class – i.e., the object's address is (numerically) the same as when it was originally dispensed by ALLOCATOR
. The non-"raw" deleteObject
has no such restriction. Note that this component will fail to compile when instantiated for a class that gives a false-positive for the type trait bsl::is_polymorphic
. See the bslmf_ispolymporphic component for more details.
The following my_RawDeleterGuard
class defines a guard that unconditionally deletes a managed object upon destruction. Via the deleteObjectRaw
method supplied by this component, the guard's destructor first destroys the managed object, then deallocates the footprint of the object. The declaration of my_RawDeleterGuard
follows:
The deleteObjectRaw
method is used in the destructor as follows:
Note that we have denoted our guard to be a "raw" guard in keeping with this use of deleteObjectRaw
(as opposed to deleteObject
).