[#BloombergLP-bslma-SharedPtrInplaceRep] = xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bslma.adoc[bslma]::SharedPtrInplaceRep :relfileprefix: ../../ :mrdocs: This class provides a concrete implementation of the `SharedPtrRep` protocol for "in‐place" instances of the parameterized `TYPE`. Upon destruction of this object, the destructor of `TYPE` is invoked. == Synopsis Declared in `<bslma_sharedptrinplacerep.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<class TYPE> class SharedPtrInplaceRep : public xref:BloombergLP/bslma/SharedPtrRep.adoc[SharedPtrRep] ---- == Base Classes [cols="1,4"] |=== | Name| Description | `xref:BloombergLP/bslma/SharedPtrRep.adoc[SharedPtrRep]` | This 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. |=== == Member Functions [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bslma/SharedPtrInplaceRep/2constructor.adoc[`SharedPtrInplaceRep`] [.small]#[constructor]# | Create a `SharedPtrInplaceRep` object having an "in‐place" instance of the parameterized `TYPE` using the `TYPE` constructor that takes the specified arguments, `args...`. Use the specified `basicAllocator` to supply memory and, upon a call to `disposeRep`, to destroy this representation (and the "in‐place" shared object). If construction of `TYPE` with `args` does not throw, then invocation of this constructor does not throw. | xref:BloombergLP/bslma/SharedPtrRep/acquireRef.adoc[`acquireRef`] | Atomically acquire a shared reference to the shared object referred to by this representation. The behavior is undefined unless `0 < numReferences()`. | xref:BloombergLP/bslma/SharedPtrRep/acquireWeakRef.adoc[`acquireWeakRef`] | Atomically acquire a weak reference to the shared object referred to by this representation. The behavior is undefined unless `0 < numWeakReferences() || 0 < numReferences()`. | xref:BloombergLP/bslma/SharedPtrInplaceRep/disposeObject.adoc[`disposeObject`] [.small]#[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. Note that this function calls the destructor for the shared object, but does not deallocate its footprint. | xref:BloombergLP/bslma/SharedPtrInplaceRep/disposeRep.adoc[`disposeRep`] [.small]#[virtual]# | Deallocate the memory associated with this representation object (including the shared object's footprint). 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 `disposeRep` method effectively serves as the representation object's destructor. | xref:BloombergLP/bslma/SharedPtrInplaceRep/getDeleter.adoc[`getDeleter`] [.small]#[virtual]# | Return a null pointer. Note that the specified `type` is not used as an in‐place representation for a shared pointer can never store a user‐supplied deleter (there is no function that might try to create one). | xref:BloombergLP/bslma/SharedPtrRep/hasUniqueOwner.adoc[`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. | xref:BloombergLP/bslma/SharedPtrRep/incrementRefs.adoc[`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()`. | xref:BloombergLP/bslma/SharedPtrRep/numReferences.adoc[`numReferences`] | Return a "snapshot" of the current number of shared references to the shared object referred to by this representation object. | xref:BloombergLP/bslma/SharedPtrRep/numWeakReferences.adoc[`numWeakReferences`] | Return a "snapshot" of the current number of weak references to the shared object referred to by this representation object. | xref:BloombergLP/bslma/SharedPtrInplaceRep/originalPtr.adoc[`originalPtr`] [.small]#[virtual]# | Return the (untyped) address of the modifiable (in‐place) object referred to by this representation object. | xref:BloombergLP/bslma/SharedPtrInplaceRep/ptr.adoc[`ptr`] | Return the address of the modifiable (in‐place) object referred to by this representation object. | xref:BloombergLP/bslma/SharedPtrRep/releaseRef.adoc[`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()`. | xref:BloombergLP/bslma/SharedPtrRep/releaseWeakRef.adoc[`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()`. | xref:BloombergLP/bslma/SharedPtrRep/resetCountsRaw.adoc[`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`. | xref:BloombergLP/bslma/SharedPtrRep/tryAcquireRef.adoc[`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 [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bslma/SharedPtrRep/managedPtrDeleter.adoc[`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`. | xref:BloombergLP/bslma/SharedPtrRep/managedPtrEmptyDeleter.adoc[`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`. |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#