Quick Links: |
Provide primitive algorithms that destroy scalars. More...
Namespaces | |
namespace | bslalg |
Typedefs | |
typedef bslalg::ScalarDestructionPrimitives | bslalg_ScalarDestructionPrimitives |
bslalg::ScalarDestructionPrimitives | namespace for scalar algorithms |
Trait Note ------------------------------- ------------------------------------- bsl::is_trivially_copyable Expressed in English as "TYPE has the bit-wise copyable trait", or "TYPE is bit-wise copyable", this trait also implies that destructor calls can be elided with no effect on observable behavior.
bslstl
package. Other clients should use the STL algorithms (in header <algorithm>
and <memory>
). 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. MyInteger
class that represents an integer value: class MyInteger { // This class represents an integer value. // DATA int d_intValue; // integer value public: // CREATORS MyInteger(); // Create a 'MyInteger' object having integer value '0'. explicit MyInteger(int value); // Create a 'MyInteger' object having the specified 'value'. ~MyInteger(); // Destroy this object. // ACCESSORS int getValue() const; };
myInteger
, of type MyInteger
: bsls::ObjectBuffer<MyInteger> buffer; MyInteger *myInteger = &buffer.object(); new (myInteger) MyInteger(1);
ObjectBuffer
to allow us to safely invoke the destructor explicitly. int scalarInteger = 2;
bslalg::ScalarDestructionPrimitives:destroy
method to destroy both myInteger
and scalarInteger
: bslalg::ScalarDestructionPrimitives::destroy(myInteger); bslalg::ScalarDestructionPrimitives::destroy(&scalarInteger);