aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAlexey Rusakov <Kitsune-Ral@users.sf.net>2022-07-07 18:32:48 +0200
committerAlexey Rusakov <Kitsune-Ral@users.sf.net>2022-07-07 18:33:23 +0200
commit64948b6840032b04ef00bfe207baa29dd445d141 (patch)
tree50dbee36f11182f311af5b0adb0102121e858bad /lib
parentbc8e01df4286f5f8ff9103fbebad801f355db689 (diff)
downloadlibquotient-64948b6840032b04ef00bfe207baa29dd445d141.tar.gz
libquotient-64948b6840032b04ef00bfe207baa29dd445d141.zip
Avoid std::derived_from and std::bind_front
Apple Clang doesn't have those yet.
Diffstat (limited to 'lib')
-rw-r--r--lib/events/event.h2
-rw-r--r--lib/qt_connection_util.h17
2 files changed, 14 insertions, 5 deletions
diff --git a/lib/events/event.h b/lib/events/event.h
index a966e613..05eb51e9 100644
--- a/lib/events/event.h
+++ b/lib/events/event.h
@@ -344,7 +344,7 @@ inline auto eventCast(const BasePtrT& eptr)
namespace _impl {
template <typename FnT, class BaseT>
concept Invocable_With_Downcast =
- std::derived_from<std::remove_cvref_t<fn_arg_t<FnT>>, BaseT>;
+ std::is_base_of_v<BaseT, std::remove_cvref_t<fn_arg_t<FnT>>>;
}
template <class BaseT, typename TailT>
diff --git a/lib/qt_connection_util.h b/lib/qt_connection_util.h
index 7477273f..edcdc572 100644
--- a/lib/qt_connection_util.h
+++ b/lib/qt_connection_util.h
@@ -46,7 +46,7 @@ namespace _impl {
template <typename SlotT, typename ReceiverT>
concept PmfSlot =
(fn_arg_count_v<SlotT> > 0
- && std::derived_from<ReceiverT, std::decay_t<fn_arg_t<SlotT, 0>>>);
+ && std::is_base_of_v<std::decay_t<fn_arg_t<SlotT, 0>>, ReceiverT>);
} // namespace _impl
//! \brief Create a connection that self-disconnects when its slot returns true
@@ -78,12 +78,21 @@ inline auto connectSingleShot(auto* sender, auto signal, ContextT* context,
Qt::ConnectionType(connType
| Qt::SingleShotConnection));
#else
- // In case for usual Qt slots passed as pointers-to-members the receiver
+ // In case of classic Qt pointer-to-member-function slots the receiver
// object has to be pre-bound to the slot to make it self-contained
if constexpr (_impl::PmfSlot<SlotT, ContextT>) {
+ auto&& boundSlot =
+# if __cpp_lib_bind_front // Needs Apple Clang 13 (other platforms are fine)
+ std::bind_front(slot, context);
+# else
+ [context, slot](const auto&... args)
+ requires requires { (context->*slot)(args...); }
+ {
+ (context->*slot)(args...);
+ };
+# endif
return _impl::connect<_impl::SingleShot>(sender, signal, context,
- std::bind_front(slot, context),
- connType);
+ std::move(boundSlot), connType);
} else {
return _impl::connect<_impl::SingleShot>(sender, signal, context, slot,
connType);