QScopedPointer uses delete []

  • Why QScopedPointer uses delete [] instead of simpledelete?

    template <typename T>
    struct QScopedPointerArrayDeleter
        static inline void cleanup(T *pointer)
            // Enforce a complete type.
            // If you get a compile error here, read the section on forward declared
            // classes in the QScopedPointer documentation.
            typedef char IsIncompleteType[ sizeof(T) ? 1 : -1 ];
            (void) sizeof(IsIncompleteType);
            delete [] pointer;

  • Qt Champions 2018

    You chose what to use by specifying the second template argument.
    QScopedPointer<int> uses delete
    QScopedPointer<int,QScopedPointerArrayDeleter> uses delete []

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.