|
BDE 4.14.0 Production release
|
Typedefs | |
| typedef bslalg::ScalarDestructionPrimitives | bslalg_ScalarDestructionPrimitives |
| This alias is defined for backward compatibility. | |
Provide primitive algorithms that destroy scalars.
This component provides utilities to destroy scalars with a uniform interface, but select a different implementation according to the traits possessed by the underlying type.
The trait under consideration by this component is:
In this section we show intended use of this component. Note that this component is for use by the bslstl package. Other clients should use the STL algorithms (in header <algorithm> and <memory>).
In this example, we will use bslalg::ScalarDestructionPrimitives to destroy both a scalar integer and a MyInteger type object. Calling the destroy method on a scalar integer is a no-op while calling the destroy method on an object of MyInteger class invokes the destructor of the object.
First, we define a MyInteger class that represents an integer value:
Then, we create an object, myInteger, of type MyInteger:
Notice that we use an ObjectBuffer to allow us to safely invoke the destructor explicitly.
Now, we define a primitive integer:
Finally, we use the uniform bslalg::ScalarDestructionPrimitives:destroy method to destroy both myInteger and scalarInteger: