From 4f191cf6578d097e604404efb72c074e608e7338 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Mon, 2 Oct 2023 07:08:02 +0200 Subject: [PATCH] QPointer: plaster API with noexcept Mark almost all public functions of the clas as noexcept. Exceptions: - assignment and construction from T*: allocates an ExtraData in QObjectPrivate - dereference: the std types do that, but it's not 100% correct, so not proposed in this patch As a drive-by, remove pointless inline keywords. Change-Id: Ice91dfc429a4268546c0b8275da329be05f4edcb Reviewed-by: Thiago Macieira Reviewed-by: Giuseppe D'Angelo --- src/corelib/kernel/qpointer.h | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/corelib/kernel/qpointer.h b/src/corelib/kernel/qpointer.h index 2da21d7dd2..25267e388e 100644 --- a/src/corelib/kernel/qpointer.h +++ b/src/corelib/kernel/qpointer.h @@ -28,7 +28,7 @@ class QPointer QWeakPointer wp; public: Q_NODISCARD_CTOR - QPointer() = default; + QPointer() noexcept = default; Q_NODISCARD_CTOR inline QPointer(T *p) : wp(p, true) { } // compiler-generated copy/move ctor/assignment operators are fine! @@ -67,30 +67,30 @@ public: inline QPointer &operator=(T* p) { wp.assign(static_cast(p)); return *this; } - inline T* data() const + T* data() const noexcept { return static_cast(wp.internalData()); } - inline T* get() const + T* get() const noexcept { return data(); } - inline T* operator->() const + T* operator->() const noexcept { return data(); } inline T& operator*() const { return *data(); } - inline operator T*() const + operator T*() const noexcept { return data(); } - inline bool isNull() const + bool isNull() const noexcept { return wp.isNull(); } - inline void clear() + void clear() noexcept { wp.clear(); } friend void swap(QPointer &lhs, QPointer &rhs) noexcept { lhs.swap(rhs); } #define DECLARE_COMPARE_SET(T1, A1, T2, A2) \ - friend bool operator==(T1, T2) \ + friend bool operator==(T1, T2) noexcept \ { return A1 == A2; } \ - friend bool operator!=(T1, T2) \ + friend bool operator!=(T1, T2) noexcept \ { return A1 != A2; } #define DECLARE_TEMPLATE_COMPARE_SET(T1, A1, T2, A2) \