BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bslma::ManagedPtr_Members Class Reference

#include <bslma_managedptr_members.h>

Public Member Functions

 ManagedPtr_Members ()
 
 ManagedPtr_Members (ManagedPtr_Members &other)
 
 ManagedPtr_Members (void *object, void *factory, DeleterFunc deleter)
 
 ManagedPtr_Members (void *object, void *factory, DeleterFunc deleter, void *alias)
 
 ~ManagedPtr_Members ()=default
 
void clear ()
 
void move (ManagedPtr_Members *other)
 
void moveAssign (ManagedPtr_Members *other)
 
void set (void *object, void *factory, DeleterFunc deleter)
 
void setAliasPtr (void *alias)
 
void swap (ManagedPtr_Members &other)
 
const ManagedPtrDeleterdeleter () const
 
void * pointer () const
 
void runDeleter () const
 

Detailed Description

This class provides a type-agnostic container for managed pointer data members. This type exists so that a ManagedPtr_Ref (see bslma_managedptr ) can point to the representation of a ManagedPtr even if the ManagedPtr_Ref object is instantiated on a different type than the managed pointer type (e.g., in the case of conversions or aliasing). ManagedPtr_Members also "erases" the type of each member, so that the same object code can be shared between all instantiations of the ManagedPtr class template, reducing template bloat. Note that objects of this type have an "unset" state, where the pointer member has a null value and the deleter member has an unspecified value.

See bslma_managedptr_members

Constructor & Destructor Documentation

◆ ManagedPtr_Members() [1/4]

bslma::ManagedPtr_Members::ManagedPtr_Members ( )
inline

Create a ManagedPtr_Members object in an unset state, i.e., where pointer is null and deleter has an unspecified value.

◆ ManagedPtr_Members() [2/4]

bslma::ManagedPtr_Members::ManagedPtr_Members ( ManagedPtr_Members other)
inlineexplicit

Create a ManagedPtr_Members object having the same pointer as the specified other object, and, if 0 != other.pointer(), the same deleter as other, then put other into an unset state.

◆ ManagedPtr_Members() [3/4]

bslma::ManagedPtr_Members::ManagedPtr_Members ( void *  object,
void *  factory,
DeleterFunc  deleter 
)
inline

Create a ManagedPtr_Members object having the specified object, factory, and deleter. The newly created object does not manage a pointer if 0 == object. The behavior is undefined unless object is null if deleter is null.

◆ ManagedPtr_Members() [4/4]

bslma::ManagedPtr_Members::ManagedPtr_Members ( void *  object,
void *  factory,
DeleterFunc  deleter,
void *  alias 
)
inline

Create a ManagedPtr_Members object having the specified object, factory, deleter, and alias. The newly created object does not manage a pointer if 0 == object. The behavior is undefined unless object is null if deleter is null, and 0 == object if and only if 0 == alias. Note that this constructor is important for managed pointers pointing to one of multiple base classes of a class using multiple inheritance.

◆ ~ManagedPtr_Members()

bslma::ManagedPtr_Members::~ManagedPtr_Members ( )
default

Member Function Documentation

◆ clear()

void bslma::ManagedPtr_Members::clear ( )
inline

Reset this object to an unset state with no effect on the previously managed object (if any).

◆ deleter()

const ManagedPtrDeleter & bslma::ManagedPtr_Members::deleter ( ) const
inline

Return a reference providing non-modifiable access to the deleter used to destroy the currently managed object (if any). The behavior is undefined unless pointer is not null.

◆ move()

void bslma::ManagedPtr_Members::move ( ManagedPtr_Members other)
inline

Reset this object to have the same pointer as the specified other object, and, if 0 != other->pointer(), the same deleter as other, then put other into an unset state. This method has no effect on the previously managed object (if any). The behavior is undefined unless this != other.

◆ moveAssign()

void bslma::ManagedPtr_Members::moveAssign ( ManagedPtr_Members other)
inline

Destroy the currently managed object (if any), reset this object to have the same pointer as the specified other object, and, if 0 != other->pointer(), the same deleter as other, then put other into an unset state. This method has no effect if this == other.

◆ pointer()

void * bslma::ManagedPtr_Members::pointer ( ) const
inline

Return the address providing modifiable access to the currently managed object, or 0 if this object is in an unset state. Note that the returned pointer may be an alias to the managed object.

◆ runDeleter()

void bslma::ManagedPtr_Members::runDeleter ( ) const
inline

Destroy the currently managed object (if any). Note that calling this method twice on an object that is not in an unset state, without assigning a new pointer to manage between the two calls, results in undefined behavior unless this object's deleter specifically supports such usage.

◆ set()

void bslma::ManagedPtr_Members::set ( void *  object,
void *  factory,
DeleterFunc  deleter 
)
inline

Reset this object to have the specified object, factory, and deleter with no effect on the previously managed object (if any). The object does not manage a pointer if 0 == object. The behavior is undefined unless object is null if deleter is null.

◆ setAliasPtr()

void bslma::ManagedPtr_Members::setAliasPtr ( void *  alias)
inline

Set pointer to have the specified alias. If 0 == alias, then this object will have an unset state with no effect on the previously managed object (if any). The behavior is undefined unless 0 == pointer() if and only if 0 == alias.

◆ swap()

void bslma::ManagedPtr_Members::swap ( ManagedPtr_Members other)

Efficiently exchange the state of this object with the state of the specified other object. This method provides the no-throw exception-safety guarantee. Note that if either object is in an unset state, then the only guarantee about the unset state that may be exchanged is that the pointer value shall be null.


The documentation for this class was generated from the following file: