Qt Reference Documentation

QScopedArrayPointer Class Reference

The QScopedArrayPointer class stores a pointer to a dynamically allocated array of objects, and deletes it upon destruction. More...

 #include <QScopedArrayPointer>

Inherits QScopedPointer<T, Cleanup>.

Note: All functions in this class are reentrant.

This class was introduced in Qt 4.6.

Public Functions

QScopedArrayPointer ( T * p = 0 )
T & operator[] ( int i )
const T & operator[] ( int i ) const

Detailed Description

The QScopedArrayPointer class stores a pointer to a dynamically allocated array of objects, and deletes it upon destruction.

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:

 void foo()
 {
     QScopedArrayPointer<int> i(new int[10]);
     i[2] = 42;
     ...
     return; // our integer array is now deleted using delete[]
 }

Member Function Documentation

QScopedArrayPointer::QScopedArrayPointer ( T * p = 0 )

Constructs this QScopedArrayPointer instance and sets its pointer to p.

T & QScopedArrayPointer::operator[] ( int i )

Provides access to entry i of the scoped pointer's array of objects.

If the contained pointer is null, behavior is undefined.

See also isNull().

const T & QScopedArrayPointer::operator[] ( int i ) const

Provides access to entry i of the scoped pointer's array of objects.

If the contained pointer is null, behavior is undefined.

See also isNull().

X

Thank you for giving your feedback.

Make sure it is related to this specific page. For more general bugs and requests, please use the Qt Bug Tracker.

[0]; s.parentNode.insertBefore(ga, s); })();