summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMartin Smith <msmith@trolltech.com>2010-02-23 12:43:50 (GMT)
committerMartin Smith <msmith@trolltech.com>2010-02-23 12:43:50 (GMT)
commit28e3d3516ebe88f7353fde44194aba5b7d1d8710 (patch)
tree0a0470a624e585cbfdb9763e145b0b2dacd62daa /src
parent9629681e7b3d69456bd6c5905c267b3d08b6243f (diff)
downloadQt-28e3d3516ebe88f7353fde44194aba5b7d1d8710.zip
Qt-28e3d3516ebe88f7353fde44194aba5b7d1d8710.tar.gz
Qt-28e3d3516ebe88f7353fde44194aba5b7d1d8710.tar.bz2
doc: Added QScopedArrayPointer and corrected QScopedPointer snippet.
Task: QTBUG-7766
Diffstat (limited to 'src')
-rw-r--r--src/corelib/tools/qscopedpointer.cpp55
1 files changed, 55 insertions, 0 deletions
diff --git a/src/corelib/tools/qscopedpointer.cpp b/src/corelib/tools/qscopedpointer.cpp
index 12badf0..e7dd769 100644
--- a/src/corelib/tools/qscopedpointer.cpp
+++ b/src/corelib/tools/qscopedpointer.cpp
@@ -225,4 +225,59 @@ QT_BEGIN_NAMESPACE
Swap this pointer with \a other.
*/
+/*!
+ \class QScopedArrayPointer
+
+ \brief The QScopedArrayPointer class stores a pointer to a
+ dynamically allocated array of objects, and deletes it upon
+ destruction.
+
+ \since 4.6
+ \reentrant
+ \ingroup misc
+
+ A QScopedArrayPointer is a QScopedPointer that defaults to
+ deleting the object it is pointing to with the delete[] operator. It
+ also features operator[] for convenience, so we can write:
+
+ \code
+ void foo()
+ {
+ QScopedArrayPointer<int> i(new int[10]);
+ i[2] = 42;
+ ...
+ return; // our integer array is now deleted using delete[]
+ }
+ \endcode
+*/
+
+/*!
+ \fn QScopedArrayPointer::QScopedArrayPointer(T *p = 0)
+
+ Constructs this QScopedArrayPointer instance and sets its pointer
+ to \a p.
+*/
+
+/*!
+ \fn T *QScopedArrayPointer::operator[](int i)
+
+ Provides access to entry \a i of the scoped pointer's array of
+ objects.
+
+ If the contained pointer is \c null, behavior is undefined.
+
+ \sa isNull()
+*/
+
+/*!
+ \fn T *QScopedArrayPointer::operator[](int i) const
+
+ Provides access to entry \a i of the scoped pointer's array of
+ objects.
+
+ If the contained pointer is \c null, behavior is undefined.
+
+ \sa isNull()
+*/
+
QT_END_NAMESPACE