diff --git a/src/corelib/tools/qscopedpointer.h b/src/corelib/tools/qscopedpointer.h index 2297d7cb1e..314e89374b 100644 --- a/src/corelib/tools/qscopedpointer.h +++ b/src/corelib/tools/qscopedpointer.h @@ -49,7 +49,7 @@ QT_BEGIN_NAMESPACE template struct QScopedPointerDeleter { - static inline void cleanup(T *pointer) + static inline void cleanup(T *pointer) noexcept { // Enforce a complete type. // If you get a compile error here, read the section on forward declared @@ -59,12 +59,16 @@ struct QScopedPointerDeleter delete pointer; } + void operator()(T *pointer) const noexcept + { + cleanup(pointer); + } }; template struct QScopedPointerArrayDeleter { - static inline void cleanup(T *pointer) + static inline void cleanup(T *pointer) noexcept { // Enforce a complete type. // If you get a compile error here, read the section on forward declared @@ -74,11 +78,16 @@ struct QScopedPointerArrayDeleter delete[] pointer; } + void operator()(T *pointer) const noexcept + { + cleanup(pointer); + } }; struct QScopedPointerPodDeleter { - static inline void cleanup(void *pointer) { if (pointer) free(pointer); } + static inline void cleanup(void *pointer) noexcept { free(pointer); } + void operator()(void *pointer) const noexcept { cleanup(pointer); } }; #ifndef QT_NO_QOBJECT @@ -86,6 +95,7 @@ template struct QScopedPointerObjectDeleteLater { static inline void cleanup(T *pointer) { if (pointer) pointer->deleteLater(); } + void operator()(T *pointer) const { cleanup(pointer); } }; class QObject;