BDE 4.14.0 Production release
|
Typedefs | |
typedef bslalg::ArrayDestructionPrimitives | bslalg_ArrayDestructionPrimitives |
This alias is defined for backward compatibility. | |
Provide primitive algorithms that destroy arrays.
This component provides utilities to destroy arrays with a uniform interface, but selecting a different implementation according to the traits possessed by the underlying type.
The traits under consideration by this component are:
TBD: maybe fix up usage example to show with allocator 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::ArrayDestructionPrimitives
to destroy both an array of integer scalars and an array of MyInteger
objects. Calling the destroy
method on an array of integers is a no-op while calling the destroy
method on an array of objects of MyInteger
class invokes the destructor of each of the objects in the array.
First, we define a MyInteger
class that contains an integer value:
Then, we create an array of objects, myIntegers
, of type MyInteger
(note that we bsls::ObjectBuffer
to allow us to safely invoke the destructor explicitly):
Now, we define a primitive integer array:
Finally, we use the uniform bslalg::ArrayDestructionPrimitives:destroy
method to destroy both myIntegers
and scalarIntegers
: