libcommonc++  0.7
ScopedPtr< T > Class Template Reference

A non-copyable scoped pointer. More...

#include <ScopedPtr.h++>

Public Member Functions

 ScopedPtr ()
 Construct a new, NULL ScopedPtr. More...
 
 ScopedPtr (T *object)
 Construct a new ScopedPtr for the given object pointer. More...
 
 ~ScopedPtr ()
 Destructor. More...
 
T & operator* () const
 Dereference operator. More...
 
T * operator-> () const
 Pointer-to-member operator. More...
 
void reset (T *object=NULL)
 Reset the pointer. More...
 
T * get () const
 Get the value of the pointer. More...
 
T * release ()
 Release ownership of the object. More...
 
bool operator! () const
 Test if the pointer is NULL. More...
 
 operator const void * () const
 Boolean test operator. More...
 
bool isNull () const
 Test if the pointer is NULL. More...
 
void swap (ScopedPtr &other)
 Swap this pointer with another. More...
 

Detailed Description

template<class T>
class ccxx::ScopedPtr< T >

A non-copyable scoped pointer.

Maintains a pointer to another object, which is deleted automatically when the ScopedPtr itself is destroyed.

Author
Mark Lindner

Constructor & Destructor Documentation

◆ ScopedPtr() [1/2]

ScopedPtr ( )
inline

Construct a new, NULL ScopedPtr.

◆ ScopedPtr() [2/2]

ScopedPtr ( T *  object)
inlineexplicit

Construct a new ScopedPtr for the given object pointer.

◆ ~ScopedPtr()

~ScopedPtr ( )
inline

Destructor.

Member Function Documentation

◆ get()

T* get ( ) const
inline

Get the value of the pointer.

◆ isNull()

bool isNull ( ) const
inline

Test if the pointer is NULL.

◆ operator const void *()

operator const void * ( ) const
inline

Boolean test operator.

(Test if the pointer is non-NULL.)

◆ operator!()

bool operator! ( ) const
inline

Test if the pointer is NULL.

◆ operator*()

T& operator* ( ) const
inline

Dereference operator.

Exceptions
NullPointerExceptionIf this pointer is NULL.

◆ operator->()

T* operator-> ( ) const
inline

Pointer-to-member operator.

Exceptions
NullPointerExceptionIf this pointer is NULL.

◆ release()

T* release ( )
inline

Release ownership of the object.

◆ reset()

void reset ( T *  object = NULL)
inline

Reset the pointer.

The old object, if any, is deleted.

◆ swap()

void swap ( ScopedPtr< T > &  other)
inline

Swap this pointer with another.


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