diff options
Diffstat (limited to 'src/corelib/thread/qfuture.h')
-rw-r--r-- | src/corelib/thread/qfuture.h | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/corelib/thread/qfuture.h b/src/corelib/thread/qfuture.h index 7aed38be16..c450221769 100644 --- a/src/corelib/thread/qfuture.h +++ b/src/corelib/thread/qfuture.h @@ -191,6 +191,14 @@ QT_WARNING_POP template<class Function, typename = std::enable_if_t<std::is_invocable_r_v<T, Function>>> QFuture<T> onCanceled(QObject *context, Function &&handler); +#if !defined(Q_CLANG_QDOC) + template<class U = T, typename = std::enable_if_t<QtPrivate::isQFutureV<U>>> + auto unwrap(); +#else + template<class U> + QFuture<U> unwrap(); +#endif + class const_iterator { public: @@ -317,6 +325,8 @@ private: template<typename ResultType> friend struct QtPrivate::WhenAnyContext; + friend struct QtPrivate::UnwrapHandler; + using QFuturePrivate = std::conditional_t<std::is_same_v<T, void>, QFutureInterfaceBase, QFutureInterface<T>>; @@ -431,6 +441,16 @@ QFuture<T> QFuture<T>::onCanceled(QObject *context, Function &&handler) return promise.future(); } +template<class T> +template<class U, typename> +auto QFuture<T>::unwrap() +{ + if constexpr (QtPrivate::isQFutureV<typename QtPrivate::Future<T>::type>) + return QtPrivate::UnwrapHandler::unwrapImpl(this).unwrap(); + else + return QtPrivate::UnwrapHandler::unwrapImpl(this); +} + inline QFuture<void> QFutureInterface<void>::future() { return QFuture<void>(this); |