IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)

QScopedArrayPointer Class

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

All functions in this class are reentrant.

Article lu   fois.

L'auteur

Liens sociaux

Viadeo Twitter Facebook Share on Google+   

QScopedArrayPointer Class

  • Header: QScopedArrayPointer

  • CMake:

    find_package(Qt6 REQUIRED COMPONENTS Core)

    target_link_libraries(mytarget PRIVATE Qt6::Core)

  • qmake: QT += core

  • Inherits: QScopedPointer

  • Group: QScopedArrayPointer is part of misc

Detailed Description

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:

 
Sélectionnez
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()

Constructs a QScopedArrayPointer instance.

[explicit] QScopedArrayPointer::QScopedArrayPointer(D *p)

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

Obsolete Members for QScopedArrayPointer

The following members of class QScopedArrayPointer are deprecated. We strongly advise against using them in new code.

Obsolete Member Function Documentation

 
void QScopedArrayPointer::swap(QScopedArrayPointer<T, Cleanup> &other)

This function is deprecated since 6.1. We strongly advise against using it in new code.

Use std::unique_ptr instead; this function may let a pointer escape its scope.

Swap this pointer with other.

Vous avez aimé ce tutoriel ? Alors partagez-le en cliquant sur les boutons suivants : Viadeo Twitter Facebook Share on Google+