All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Public Member Functions | List of all members
autoPtr< T > Class Template Reference

An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and with pointer allocation checking on access. More...

Inherited by LList< Foam::autoPtr< Foam::regExp > >.

Public Types

typedef T Type
 

Public Member Functions

 autoPtr (T *=nullptr)
 Store object pointer. More...
 
 autoPtr (const autoPtr< T > &)
 Construct as copy by transferring pointer to this autoPtr and. More...
 
 autoPtr (const autoPtr< T > &, const bool reuse)
 Construct either by transferring pointer or cloning. More...
 
 ~autoPtr ()
 Destructor, delete object if pointer is not nullptr. More...
 
bool empty () const
 Return true if the autoPtr is empty (ie, no pointer set) More...
 
bool valid () const
 Return true if the autoPtr valid (ie, the pointer is set) More...
 
Tptr ()
 Return object pointer for reuse. More...
 
void set (T *)
 Set pointer to that given. More...
 
void reset (T *=nullptr)
 If object pointer already set, delete object and set to given. More...
 
void clear ()
 Delete object (if the pointer is valid) and set pointer to. More...
 
Toperator() ()
 Return reference to the object data. More...
 
const Toperator() () const
 Return const reference to the object data. More...
 
Toperator* ()
 Return reference to the object data. More...
 
const Toperator* () const
 Return const reference to the object data. More...
 
 operator const T & () const
 Const cast to the underlying type reference. More...
 
Toperator-> ()
 Return object pointer. More...
 
const Toperator-> () const
 Return const object pointer. More...
 
void operator= (T *)
 Take over the object pointer from parameter. More...
 
void operator= (const autoPtr< T > &)
 Take over the object pointer from parameter. More...
 

Detailed Description

template<class T>
class Foam::autoPtr< T >

An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and with pointer allocation checking on access.

Source files

Definition at line 52 of file PtrList.H.

Member Typedef Documentation

◆ Type

typedef T Type

Definition at line 60 of file autoPtr.H.

Constructor & Destructor Documentation

◆ autoPtr() [1/3]

autoPtr ( T p = nullptr)
inlineexplicit

Store object pointer.

Definition at line 32 of file autoPtrI.H.

◆ autoPtr() [2/3]

autoPtr ( const autoPtr< T > &  ap)
inline

Construct as copy by transferring pointer to this autoPtr and.

setting the arguments pointer to nullptr

Definition at line 39 of file autoPtrI.H.

◆ autoPtr() [3/3]

autoPtr ( const autoPtr< T > &  ap,
const bool  reuse 
)
inline

Construct either by transferring pointer or cloning.

Should only be called with type that supports cloning

Definition at line 48 of file autoPtrI.H.

◆ ~autoPtr()

~autoPtr ( )
inline

Destructor, delete object if pointer is not nullptr.

Definition at line 67 of file autoPtrI.H.

Member Function Documentation

◆ empty()

bool empty ( ) const
inline

Return true if the autoPtr is empty (ie, no pointer set)

Definition at line 76 of file autoPtrI.H.

Referenced by sampledIsoSurfaceCell::faces(), sampledCuttingPlane::faces(), distanceSurface::faces(), and sampledIsoSurface::faces().

Here is the caller graph for this function:

◆ valid()

bool valid ( ) const
inline

◆ ptr()

T * ptr ( )
inline

◆ set()

void set ( T p)
inline

Set pointer to that given.

If object pointer already set issue a FatalError

Definition at line 99 of file autoPtrI.H.

Referenced by searchablePlateFeatures::features(), rigidBodyModel::merge(), and functionObjectList::read().

Here is the caller graph for this function:

◆ reset()

void reset ( T p = nullptr)
inline

◆ clear()

void clear ( )
inline

Delete object (if the pointer is valid) and set pointer to.

nullptr

Definition at line 126 of file autoPtrI.H.

Referenced by polyMeshAdder::add(), meshRefinement::distribute(), verticalDamping::read(), masterUncollatedFileOperation::readStream(), and OFstreamCollator::~OFstreamCollator().

Here is the caller graph for this function:

◆ operator()() [1/2]

T & operator() ( )
inline

Return reference to the object data.

Definition at line 135 of file autoPtrI.H.

◆ operator()() [2/2]

const T & operator() ( ) const
inline

Return const reference to the object data.

Definition at line 150 of file autoPtrI.H.

◆ operator*() [1/2]

T & operator* ( )
inline

Return reference to the object data.

Definition at line 165 of file autoPtrI.H.

◆ operator*() [2/2]

const T & operator* ( ) const
inline

Return const reference to the object data.

Definition at line 180 of file autoPtrI.H.

◆ operator const T &()

operator const T & ( ) const
inline

Const cast to the underlying type reference.

Definition at line 195 of file autoPtrI.H.

◆ operator->() [1/2]

T * operator-> ( )
inline

Return object pointer.

Definition at line 202 of file autoPtrI.H.

◆ operator->() [2/2]

const T * operator-> ( ) const
inline

Return const object pointer.

Definition at line 217 of file autoPtrI.H.

◆ operator=() [1/2]

void operator= ( T p)
inline

Take over the object pointer from parameter.

Definition at line 224 of file autoPtrI.H.

◆ operator=() [2/2]

void operator= ( const autoPtr< T > &  ap)
inline

Take over the object pointer from parameter.

Definition at line 231 of file autoPtrI.H.


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