Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
QScopedArrayPointer< T, Cleanup > Class Template Reference

\inmodule QtCore More...

#include <qscopedpointer.h>

+ Inheritance diagram for QScopedArrayPointer< T, Cleanup >:
+ Collaboration diagram for QScopedArrayPointer< T, Cleanup >:

Public Member Functions

Q_NODISCARD_CTOR QScopedArrayPointer ()
 Constructs a QScopedArrayPointer instance.
 
 ~QScopedArrayPointer ()=default
 
template<typename D , if_same_type< D > = true>
Q_NODISCARD_CTOR QScopedArrayPointer (D *p)
 Constructs a QScopedArrayPointer and stores the array of objects pointed to by p.
 
T & operator[] (qsizetype i)
 Provides access to entry i of the scoped pointer's array of objects.
 
const T & operator[] (qsizetype i) const
 Provides access to entry i of the scoped pointer's array of objects.
 
- Public Member Functions inherited from QScopedPointer< T, Cleanup >
Q_NODISCARD_CTOR QScopedPointer (T *p=nullptr) noexcept
 Constructs this QScopedPointer instance and sets its pointer to p.
 
 ~QScopedPointer ()
 Destroys this QScopedPointer object.
 
T & operator* () const
 Provides access to the scoped pointer's object.
 
T * operator-> () const noexcept
 Provides access to the scoped pointer's object.
 
bool operator! () const noexcept
 Returns true if this object refers to \nullptr.
 
 operator bool () const
 Returns true if the contained pointer is not \nullptr.
 
T * data () const noexcept
 Returns the value of the pointer referenced by this object.
 
T * get () const noexcept
 
bool isNull () const noexcept
 Returns true if this object refers to \nullptr.
 
void reset (T *other=nullptr) noexcept(noexcept(Cleanup::cleanup(std::declval< T * >())))
 Deletes the existing object it is pointing to (if any), and sets its pointer to other.
 

Additional Inherited Members

- Public Types inherited from QScopedPointer< T, Cleanup >
typedef T * pointer
 
- Protected Attributes inherited from QScopedPointer< T, Cleanup >
T * d
 

Detailed Description

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

\inmodule QtCore

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

Since
4.6 \reentrant

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()
{
i[2] = 42;
...
return; // our integer array is now deleted using delete[]
}
\inmodule QtCore
QString foo
[0]

Definition at line 191 of file qscopedpointer.h.

Constructor & Destructor Documentation

◆ QScopedArrayPointer() [1/2]

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

Constructs a QScopedArrayPointer instance.

Definition at line 197 of file qscopedpointer.h.

◆ ~QScopedArrayPointer()

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

◆ QScopedArrayPointer() [2/2]

template<typename T , typename Cleanup = QScopedPointerArrayDeleter<T>>
template<typename D , if_same_type< D > = true>
Q_NODISCARD_CTOR QScopedArrayPointer< T, Cleanup >::QScopedArrayPointer ( D * p)
inlineexplicit

Constructs a QScopedArrayPointer and stores the array of objects pointed to by p.

Definition at line 202 of file qscopedpointer.h.

Member Function Documentation

◆ operator[]() [1/2]

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

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

If the contained pointer is \nullptr, behavior is undefined.

Note
In Qt versions prior to 6.5, i was of type {int}, not {qsizetype}, possibly causing truncation on 64-bit platforms.
See also
isNull()

Definition at line 207 of file qscopedpointer.h.

◆ operator[]() [2/2]

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

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

If the contained pointer is \nullptr behavior is undefined.

Note
In Qt versions prior to 6.5, i was of type {int}, not {qsizetype}, possibly causing truncation on 64-bit platforms.
See also
isNull()

Definition at line 212 of file qscopedpointer.h.


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