CopperSpice API  1.7.2
QScopedArrayPointer< T, Cleanup > Class Template Reference

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

Inheritance diagram for QScopedArrayPointer< T, Cleanup >:
QScopedPointer< T, Cleanup >

Public Methods

 QScopedArrayPointer ()
 
T & operator[] (int i)
 
const T & operator[] (int i) const
 
- Public Methods inherited from QScopedPointer< T, Cleanup >
 QScopedPointer (QScopedPointer< T, Cleanup > &&other)
 
 QScopedPointer (T *p=nullptr)
 
 ~QScopedPointer ()
 
T * data () const
 
bool isNull () const
 
 operator RestrictedBool () const
 
bool operator! () const
 
T & operator* () const
 
T * operator-> () const
 
QScopedPointer< T, Cleanup > & operator= (QScopedPointer< T, Cleanup > &&other)
 
void reset (T *other=nullptr)
 
void swap (QScopedPointer< T, Cleanup > &other)
 
T * take ()
 

Detailed Description

template<typename T, typename Cleanup = QScopedPointerArrayDeleter<T>>
class QScopedArrayPointer< T, Cleanup >

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; // integer array is now deleted using delete[]
}
See also
isNull()

Constructor & Destructor Documentation

template<typename T , typename Cleanup = QScopedPointerArrayDeleter<T>>
QScopedArrayPointer< T, Cleanup >::QScopedArrayPointer ( )
inline

Constructs a QScopedArrayPointer instance.

Method Documentation

template<typename T , typename Cleanup = QScopedPointerArrayDeleter<T>>
T & QScopedArrayPointer< T, Cleanup >::operator[] ( int  i)
inline

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()
template<typename T , typename Cleanup = QScopedPointerArrayDeleter<T>>
const T & QScopedArrayPointer< T, Cleanup >::operator[] ( int  i) const
inline

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()