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>
This commit is contained in:
parent
4527b2d165
commit
6c19d1c5ea
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user