summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qscopedpointer.h
diff options
context:
space:
mode:
authorGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2020-08-21 22:48:43 +0200
committerGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2020-08-26 02:19:17 +0200
commit67c3c7a29c9bebf68a367aeb85162248b58675b3 (patch)
tree13bd2fe28bc1e845b2c4ea0e8b80a683e05f265f /src/corelib/tools/qscopedpointer.h
parent8dd50ef206f384ac781d6bb9ca5e254851531298 (diff)
Smart pointers: port to explicit operator bool
Enough with the restricted bool trick; use the established solution. [ChangeLog][Potentially Source-Incompatible Changes] QScopedPointer, QSharedPointer and QWeakPointer's conversion operator towards bool is now explicit. In some cases this may require an explicit cast towards bool that was not needed before (notably, when returning an object of these types from a function that actually returns bool). Change-Id: I02b89278e75b7e7493ee7e35460504719e00f028 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/tools/qscopedpointer.h')
-rw-r--r--src/corelib/tools/qscopedpointer.h12
1 files changed, 2 insertions, 10 deletions
diff --git a/src/corelib/tools/qscopedpointer.h b/src/corelib/tools/qscopedpointer.h
index af0c0ed336..4acec9c1f6 100644
--- a/src/corelib/tools/qscopedpointer.h
+++ b/src/corelib/tools/qscopedpointer.h
@@ -95,7 +95,6 @@ typedef QScopedPointerObjectDeleteLater<QObject> QScopedPointerDeleteLater;
template <typename T, typename Cleanup = QScopedPointerDeleter<T> >
class QScopedPointer
{
- typedef T *QScopedPointer:: *RestrictedBool;
public:
explicit QScopedPointer(T *p = nullptr) noexcept : d(p)
{
@@ -123,17 +122,10 @@ public:
return !d;
}
-#if defined(Q_QDOC)
- inline operator bool() const
+ explicit operator bool() const
{
- return isNull() ? nullptr : &QScopedPointer::d;
+ return !isNull();
}
-#else
- operator RestrictedBool() const noexcept
- {
- return isNull() ? nullptr : &QScopedPointer::d;
- }
-#endif
T *data() const noexcept
{