diff options
author | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2020-08-21 22:46:33 +0200 |
---|---|---|
committer | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2020-08-23 11:18:08 +0200 |
commit | 6c19d1c5eaf2417afa6475fdaf470cc4c3896899 (patch) | |
tree | 524cc5989bdd2ec1fba57b6ad3d798182bb36479 | |
parent | 4527b2d16537e7b6b6b8733117f536435d99175f (diff) |
Leave a comment about a usage of a restricted bool trick
I'm pretty sure we want to keep supporting statements like
bool ok = connect(~~~);
that is, statements that do use copy initialization and not
direct initialization. As such, QMetaObject::Connection has
to keep using the restricted bool trick and cannot be ported
over to explicit operator bool.
Change-Id: I07a38f7c134686e67b5984aa93fe5cf3201561d7
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
-rw-r--r-- | src/corelib/kernel/qobjectdefs.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/corelib/kernel/qobjectdefs.h b/src/corelib/kernel/qobjectdefs.h index d47c311c18..2013af1695 100644 --- a/src/corelib/kernel/qobjectdefs.h +++ b/src/corelib/kernel/qobjectdefs.h @@ -453,6 +453,8 @@ public: #ifdef Q_QDOC operator bool() const; #else + // still using the restricted bool trick here, in order to support + // code using copy-init (e.g. `bool ok = connect(...)`) typedef void *Connection::*RestrictedBool; operator RestrictedBool() const { return d_ptr && isConnected_helper() ? &Connection::d_ptr : nullptr; } #endif |