#include <bdld_manageddatum.h>
This class implements a smart-pointer-like resource manager for a Datum object.
See bdld_manageddatum
◆ allocator_type
◆ ManagedDatum() [1/6]
| bdld::ManagedDatum::ManagedDatum |
( |
| ) |
|
|
inline |
Create a ManagedDatum object having the default (null) value, and the specified allocator (e.g., the address of a bslma::Allocator object) to supply memory. Calling isNull on the resulting managed Datum object returns true.
◆ ManagedDatum() [2/6]
◆ ManagedDatum() [3/6]
Create a ManagedDatum object that assumes ownership of the specified datum. Optionally specify an allocator (e.g., the address of a bslma::Allocator object) to supply memory; otherwise, the default allocator is used.
- Precondition
- The behavior is undefined unless
datum was allocated using the indicated allocator and is not subsequently destroyed externally using Datum::destroy.
◆ ManagedDatum() [4/6]
Create a ManagedDatum object having the same value as the specified original object. Optionally specify an allocator (e.g., the address of a bslma::Allocator object) used to supply memory; otherwise, the default allocator is used. This operation performs a clone of the underlying Datum, see {Value Semantics} for more detail.
◆ ManagedDatum() [5/6]
Create a ManagedDatum object having the same value and allocator as the specified original object. The value of original becomes unspecified but valid, and its allocator remains unchanged.
◆ ManagedDatum() [6/6]
Create a ManagedDatum object having the same value as the specified original object and the specified allocator (e.g., the address of a bslma::Allocator object) used to supply memory. The allocator of original remains unchanged. If original and the newly created object have the same allocator then the value of original becomes unspecified but valid, and no exceptions will be thrown; otherwise original is unchanged and an exception may be thrown.
◆ ~ManagedDatum()
| bdld::ManagedDatum::~ManagedDatum |
( |
| ) |
|
|
inline |
Destroy this object and release all dynamically allocated memory managed by this object.
◆ adopt()
| void bdld::ManagedDatum::adopt |
( |
const Datum & |
obj | ) |
|
|
inline |
Take ownership of the specified obj and destroy the Datum object previously managed by this object.
- Precondition
- The behavior is undefined unless
obj was allocated using the same allocator used by this object and is not subsequently destroyed externally using Datum::destroy.
◆ allocator()
◆ BSLMF_NESTED_TRAIT_DECLARATION()
'ManagedDatum' objects are allocator-aware and bitwise movable.
◆ clone()
| void bdld::ManagedDatum::clone |
( |
const Datum & |
value | ) |
|
|
inline |
Assign to this object the specified value by making a "deep copy" of value, so that any dynamically allocated memory managed by value is cloned and not shared with value.
◆ datum()
| const Datum & bdld::ManagedDatum::datum |
( |
| ) |
const |
|
inline |
Return a const reference to the Datum object managed by this object.
◆ get_allocator()
Return the allocator used by this object to supply memory.
- Note
- Note that if no allocator was supplied at construction the default allocator in effect at construction is used.
◆ makeNull()
| void bdld::ManagedDatum::makeNull |
( |
| ) |
|
|
inline |
Make the Datum object managed by this object null and release all dynamically allocated memory managed by this object.
◆ operator*()
| const Datum & bdld::ManagedDatum::operator* |
( |
| ) |
const |
|
inline |
Return a const reference to the Datum object managed by this object.
◆ operator->()
| const Datum * bdld::ManagedDatum::operator-> |
( |
| ) |
const |
|
inline |
Return an address providing non-modifiable access to the Datum object managed by this object.
◆ operator=() [1/2]
Assign to this object the value of the specified rhs object, and return a non-const reference to this object. Depending on the match of the object's allocators, this operation performs either shallow (the allocators are the same) or deep (the allocators are different) copying.
◆ operator=() [2/2]
Assign to this object the value of the specified rhs object, and return a non-const reference to this object. This operation performs a clone of the underlying Datum, see {Value Semantics} for more detail.
◆ print()
| bsl::ostream & bdld::ManagedDatum::print |
( |
bsl::ostream & |
stream, |
|
|
int |
level = 0, |
|
|
int |
spacesPerLevel = 4 |
|
) |
| const |
|
inline |
Format this object to the specified output stream at the (absolute value of) the optionally specified indentation level and return a reference to the modifiable stream. If level is specified, optionally specify spacesPerLevel, the number of spaces per indentation level for this and all of its nested objects. If level is negative, suppress indentation of the first line. If spacesPerLevel is negative, format the entire output on one line, suppressing all but the initial indentation (as governed by level). If stream is not valid on entry, this operation has no effect.
◆ release()
| Datum bdld::ManagedDatum::release |
( |
| ) |
|
|
inline |
Return, by value, the Datum object managed by this object and set the managed object to null. Ownership of the previously managed Datum object is transferred to the caller.
◆ swap()
Efficiently exchange the value of this object with the value of the specified other object. This method provides the no-throw exception-safety guarantee.
- Precondition
- The behavior is undefined unless this object was created with the same allocator as
other.
The documentation for this class was generated from the following file: