QScopedPointer< T, Cleanup > Class Template Reference

QScopedPointer< T, Cleanup > Class Template Reference

#include <qscopedpointer.h>

Class Description

template<typename T, typename Cleanup = QScopedPointerDeleter<T>>
class QScopedPointer< T, Cleanup >

Definition at line 87 of file qscopedpointer.h.

+ Inheritance diagram for QScopedPointer< T, Cleanup >:

Public Types

typedef T * pointer
 

Public Member Functions

 QScopedPointer (T *p=0)
 
 ~QScopedPointer ()
 
T & operator* () const
 
T * operator-> () const
 
bool operator! () const
 
 operator RestrictedBool () const
 
T * data () const
 
bool isNull () const
 
void reset (T *other=0)
 
T * take ()
 
void swap (QScopedPointer< T, Cleanup > &other)
 

Protected Attributes

T * d
 

Member Typedef Documentation

typedef T* pointer

Definition at line 164 of file qscopedpointer.h.

Constructor & Destructor Documentation

QScopedPointer ( T *  p = 0)
inlineexplicit

Definition at line 93 of file qscopedpointer.h.

93  : d(p)
94  {
95  }
GLfloat GLfloat p
Definition: GLee.h:5416
~QScopedPointer ( )
inline

Definition at line 97 of file qscopedpointer.h.

98  {
99  T *oldD = this->d;
100  Cleanup::cleanup(oldD);
101  this->d = 0;
102  }

Member Function Documentation

T& operator* ( ) const
inline

Definition at line 104 of file qscopedpointer.h.

105  {
106  Q_ASSERT(d);
107  return *d;
108  }
T* operator-> ( void  ) const
inline

Definition at line 110 of file qscopedpointer.h.

111  {
112  Q_ASSERT(d);
113  return d;
114  }
bool operator! ( void  ) const
inline

Definition at line 116 of file qscopedpointer.h.

117  {
118  return !d;
119  }
operator RestrictedBool ( ) const
inline

Definition at line 127 of file qscopedpointer.h.

128  {
129  return isNull() ? 0 : &QScopedPointer::d;
130  }
bool isNull() const
T* data ( ) const
inline

Definition at line 133 of file qscopedpointer.h.

134  {
135  return d;
136  }
bool isNull ( ) const
inline

Definition at line 138 of file qscopedpointer.h.

139  {
140  return !d;
141  }
void reset ( T *  other = 0)
inline

Definition at line 143 of file qscopedpointer.h.

144  {
145  if (d == other)
146  return;
147  T *oldD = d;
148  d = other;
149  Cleanup::cleanup(oldD);
150  }
T* take ( )
inline

Definition at line 152 of file qscopedpointer.h.

153  {
154  T *oldD = d;
155  d = 0;
156  return oldD;
157  }
void swap ( QScopedPointer< T, Cleanup > &  other)
inline

Definition at line 159 of file qscopedpointer.h.

160  {
161  qSwap(d, other.d);
162  }
Q_INLINE_TEMPLATE void qSwap(QScopedPointer< T, Cleanup > &p1, QScopedPointer< T, Cleanup > &p2)

Member Data Documentation

T* d
protected

Definition at line 167 of file qscopedpointer.h.


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