From bf22f914410b37031acdf39ea8fef89cbbf2ca28 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Wed, 19 May 2021 10:37:24 +0200 Subject: QFuture/QPromise: don't check for is_copy_constructible MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The check is over-arching. is_move_constructible is sufficient; we don't have to support "ridiculous" types that are copiable but have deleted move operations (such types are fundamentally broken). This is in line with the Move* (legacy) named requirements. Change-Id: Idc7116b39013501b9be39628a4e7afd35fe15530 Reviewed-by: MÃ¥rten Nordheim Reviewed-by: Sona Kurazyan Reviewed-by: Andrei Golubev Reviewed-by: Ville Voutilainen --- src/corelib/thread/qfuture.h | 5 ++--- src/corelib/thread/qpromise.h | 5 ++--- tests/auto/corelib/thread/qpromise/tst_qpromise.cpp | 1 - 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/corelib/thread/qfuture.h b/src/corelib/thread/qfuture.h index 748b3a5403..8c04b8c437 100644 --- a/src/corelib/thread/qfuture.h +++ b/src/corelib/thread/qfuture.h @@ -59,10 +59,9 @@ class QFutureWatcher; template class QFuture { - static_assert (std::is_copy_constructible_v - || std::is_move_constructible_v + static_assert (std::is_move_constructible_v || std::is_same_v, - "Type with copy or move constructors or type void is required"); + "A move-constructible type or type void is required"); public: QFuture() : d(QFutureInterface::canceledResult()) diff --git a/src/corelib/thread/qpromise.h b/src/corelib/thread/qpromise.h index 68645ef084..e453f29b6a 100644 --- a/src/corelib/thread/qpromise.h +++ b/src/corelib/thread/qpromise.h @@ -52,10 +52,9 @@ QT_BEGIN_NAMESPACE template class QPromise { - static_assert (std::is_copy_constructible_v - || std::is_move_constructible_v + static_assert (std::is_move_constructible_v || std::is_same_v, - "Type with copy or move constructors or type void is required"); + "A move-constructible type or type void is required"); public: QPromise() = default; Q_DISABLE_COPY(QPromise) diff --git a/tests/auto/corelib/thread/qpromise/tst_qpromise.cpp b/tests/auto/corelib/thread/qpromise/tst_qpromise.cpp index 8321b4126f..52f4daa24a 100644 --- a/tests/auto/corelib/thread/qpromise/tst_qpromise.cpp +++ b/tests/auto/corelib/thread/qpromise/tst_qpromise.cpp @@ -77,7 +77,6 @@ private slots: struct TrivialType { int field = 0; }; struct CopyOnlyType { - Q_DISABLE_MOVE(CopyOnlyType) constexpr CopyOnlyType(int field = 0) noexcept : field(field) {} CopyOnlyType(const CopyOnlyType &) = default; CopyOnlyType& operator=(const CopyOnlyType &) = default; -- cgit v1.2.3