BloombergLP::bslstl::SharedPtrArrayAllocateInplaceRep

This class provides a concrete implementation of the SharedPtrRep protocol for in-place instances of the (template parameter) TYPE, which must be an array. Upon destruction of this object, each element of the array is destructed.

Synopsis

Declared in <bslstl_sharedptrallocateinplacerep.h>

template<
    class TYPE,
    class ALLOCATOR>
class SharedPtrArrayAllocateInplaceRep
    : public BloombergLP::bslma::SharedPtrRep

Base Classes

NameDescription
BloombergLP::bslma::SharedPtrRepThis class provides a partially implemented shared pointer representation ("letter") protocol. The class provides two counters for storing the number of shared and weak references, and functions to increment and decrement these counters. In addition, this class provides protocol methods that allow concrete implementations to specify what action should be taken when these counts reach zero. The function disposeRep is responsible for destroying this object, it is called when the reference count to this object reaches zero. Thus, the destructor of this object is declared as protected and should never be invoked.

Type Aliases

NameDescription
ReboundAllocator ReboundAllocator is the rebound allocator type.
element_type element_type is the type of the managed object.

Member Functions

NameDescription
acquireRef Atomically acquire a shared reference to the shared object referred to by this representation. The behavior is undefined unless 0 < numReferences().
acquireWeakRef Atomically acquire a weak reference to the shared object referred to by this representation. The behavior is undefined unless 0 < numWeakReferences() || 0 < numReferences().
disposeObject [virtual]Destroy the object being referred to by this representation. This method is automatically invoked by releaseRef when the number of shared references reaches zero and should not be explicitly invoked otherwise.
disposeRep [virtual]Destroy this representation object and deallocate the associated memory. This method is automatically invoked by releaseRef and releaseWeakRef when the number of weak references and the number of shared references both reach zero and should not be explicitly invoked otherwise. The behavior is undefined unless disposeObject has already been called for this representation. Note that this method effectively serves as the representation object's destructor.
getDeleter [virtual]Ignore the specified type and return a null pointer. Note that there is no facility for the user to supply a deleter for an in-place representation for a shared pointer.
hasUniqueOwner Return true if there is only one shared reference and no weak references to the object referred to by this representation, and false otherwise.
incrementRefs Atomically increment the number of shared references to the shared object referred to by this representation by the optionally specified incrementAmount. The behavior is undefined unless 0 < incrementAmount and 0 < numReferences().
numReferences Return a "snapshot" of the current number of shared references to the shared object referred to by this representation object.
numWeakReferences Return a "snapshot" of the current number of weak references to the shared object referred to by this representation object.
originalPtr [virtual]Return the (untyped) address of the modifiable shared object to which this object refers.
ptr Return the address of the modifiable shared object to which this object refers. Note that in order to return a pointer to a modifiable object, this function cannot be const qualified as the referenced object is stored internally.
releaseRef Atomically release a shared reference to the shared object referred to by this representation, disposing of the shared object if all the shared references to that object are released, and disposing of this representation if all (shared and weak) references to that object are released. The behavior is undefined unless 0 < numReferences().
releaseWeakRef Atomically release a weak reference to the shared object referred to by this representation, disposing of this representation if all (shared and weak) references to the shared object are released. The behavior is undefined unless 0 < numWeakReferences().
resetCountsRaw Reset the number of shared references and the number of weak references stored by this representation to the specified numSharedReferences and numWeakReferences respectively. This function is not thread-safe and users must ensure that they serialize access to the SharedPtrRep object when calling this function. Note that this function updates the counts, but does not dispose of the representation or the object irrespective of the values of numSharedReferences and numWeakReferences.
tryAcquireRef Atomically acquire a shared reference to the shared object referred to by this representation, if the number of shared references is greater than 0, and do nothing otherwise. Return true if the acquire succeeds, and false otherwise. The behavior is undefined unless 0 < numWeakReferences() || 0 < numReferences().

Static Member Functions

NameDescription
alloc_size Return the size (in bytes) for an allocation to hold an object of type SharedPtrArrayAllocateInplaceRep<T[]> containing the specified numElements number of elements.
makeRep Create a SharedPtrArrayAllocateInplaceRep object having storage for an in-place uninitialized sized array of (template parameter) TYPE containing space for the specified numElements number of elements, and return its address. Use the specified basicAllocator to supply memory and, upon a call to disposeRep, to destroy this representation (and the in-place shared object). Note that the function members ptr and originalPtr will return the address of an uninitialized array. This object should be explicitly initialized by the caller, and it is undefined behavior to call disposeRep until this object has been successfully constructed.
managedPtrDeleter Release the shared reference to an object held by the SharedPtrRep object that is pointed to be by specified rep. The behavior is undefined unless rep points to an object whose complete type publicly and unambiguously derives from SharedPtrRep. Note that the first argument is ignored. Also note that this function serves as the ManagedPtr deleter when converting a bsl::shared_ptr to a bslma::ManagedPtr.
managedPtrEmptyDeleter This function has no effect. The behavior is undefined unless rep is null. Note that this function serves as the managed ptr deleter when converting an empty or null bsl::shared_ptr to a bslma::ManagedPtr.