summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2023-10-02 07:08:02 +0200
committerMarc Mutz <marc.mutz@qt.io>2023-10-05 19:40:02 +0200
commit4f191cf6578d097e604404efb72c074e608e7338 (patch)
tree21257442602ff3faaaaa01921e1e784ae8652605
parentfc1549c01445bb9c99d3ba6de8fa9da230614e72 (diff)
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 <thiago.macieira@intel.com> Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
-rw-r--r--src/corelib/kernel/qpointer.h18
1 files 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<QObjectType> 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<T> &operator=(T* p)
{ wp.assign(static_cast<QObjectType*>(p)); return *this; }
- inline T* data() const
+ T* data() const noexcept
{ return static_cast<T*>(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) \