summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2022-06-10 08:07:22 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-06-14 01:31:08 +0000
commit85f56b33d4d8f4271dd9495a64d7c9b247b7edae (patch)
tree790f38847c14329ae64676fabefc6704c6f6ec43 /src/corelib
parent7c135a4e0cbd2b49da6ab1ca69fe1fc0020663f1 (diff)
Revert "qxp::function_ref: drop use of q23::invoke_r"
This reverts commit b9cce12e76796962e5e5ad0d5408370af56af459, which broke function_ref<void(int)> f = [](int i) { return i; }; ie. swallowing of return types. We could maybe implement the same without invoke_r, with the same manual if-constexpr that invoke_r has, but it would be a pointless duplication across the two thunks we have, so just use invoke_r. Add tests. Task-number: QTBUG-103739 Change-Id: I6034f05d813c06a25e8058ded5b6b62f3ca858b4 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit fa4d18b86c0cb0de495ce988fd9d3714e09b05dd) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/global/qxpfunctional.h8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/corelib/global/qxpfunctional.h b/src/corelib/global/qxpfunctional.h
index ca015be22e..67350c56ed 100644
--- a/src/corelib/global/qxpfunctional.h
+++ b/src/corelib/global/qxpfunctional.h
@@ -21,7 +21,7 @@
// We mean it.
//
-#include <QtCore/q20functional.h>
+#include <QtCore/q23functional.h>
#include <type_traits>
#include <utility>
@@ -99,7 +99,8 @@ public:
Q_IMPLICIT function_ref_base(F* f) noexcept
: m_bound_entity(f),
m_thunk_ptr([](BoundEntityType ctx, ArgTypes&&... args) noexcept(noex) -> R {
- return reinterpret_cast<F*>(ctx.fun)(std::forward<ArgTypes>(args)...);
+ return q23::invoke_r<R>(reinterpret_cast<F*>(ctx.fun),
+ std::forward<ArgTypes>(args)...);
})
{}
@@ -115,7 +116,8 @@ public:
: m_bound_entity(std::addressof(f)),
m_thunk_ptr([](BoundEntityType ctx, ArgTypes&&... args) noexcept(noex) -> R {
using That = copy_const_t<Const, std::remove_reference_t<F>>;
- return (*static_cast<That*>(ctx.obj))(std::forward<ArgTypes>(args)...);
+ return q23::invoke_r<R>(*static_cast<That*>(ctx.obj),
+ std::forward<ArgTypes>(args)...);
})
{}