aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexey Rusakov <Kitsune-Ral@users.sf.net>2021-10-04 11:05:10 +0200
committerAlexey Rusakov <Kitsune-Ral@users.sf.net>2021-10-04 11:05:10 +0200
commitc16813c5209f0421ec773a98cf935a2eb2ea3d7c (patch)
tree29af3cff94a76fafea19d93f0e47c1c37b2ae24f
parent73c1c8747b0c00524239724bb7cf00776448c5c7 (diff)
downloadlibquotient-c16813c5209f0421ec773a98cf935a2eb2ea3d7c.tar.gz
libquotient-c16813c5209f0421ec773a98cf935a2eb2ea3d7c.zip
Move away wrap_in_function to private interface
This has always been merely a workaround to enable connectUntil/connectSingleShot and was never intended to be used elsewhere, let alone in clients.
-rw-r--r--lib/qt_connection_util.h17
-rw-r--r--lib/util.h12
2 files changed, 14 insertions, 15 deletions
diff --git a/lib/qt_connection_util.h b/lib/qt_connection_util.h
index c6fa037a..9370d2eb 100644
--- a/lib/qt_connection_util.h
+++ b/lib/qt_connection_util.h
@@ -73,6 +73,17 @@ namespace _impl {
}),
connType);
}
+
+ // TODO: get rid of it as soon as Apple Clang gets proper deduction guides
+ // for std::function<>
+ // ...or consider using QtPrivate magic used by QObject::connect()
+ // ...for inspiration, also check a possible std::not_fn implementation
+ // at https://en.cppreference.com/w/cpp/utility/functional/not_fn
+ template <typename FnT>
+ inline auto wrap_in_function(FnT&& f)
+ {
+ return typename function_traits<FnT>::function_type(std::forward<FnT>(f));
+ }
} // namespace _impl
/*! \brief Create a connection that self-disconnects when its "slot" returns true
@@ -90,7 +101,7 @@ inline auto connectUntil(SenderT* sender, SignalT signal, ContextT* context,
const FunctorT& slot,
Qt::ConnectionType connType = Qt::AutoConnection)
{
- return _impl::connectUntil(sender, signal, context, wrap_in_function(slot),
+ return _impl::connectUntil(sender, signal, context, _impl::wrap_in_function(slot),
connType);
}
@@ -101,7 +112,7 @@ inline auto connectSingleShot(SenderT* sender, SignalT signal,
Qt::ConnectionType connType = Qt::AutoConnection)
{
return _impl::connectSingleShot(
- sender, signal, context, wrap_in_function(slot), connType);
+ sender, signal, context, _impl::wrap_in_function(slot), connType);
}
// Specialisation for usual Qt slots passed as pointers-to-members.
@@ -114,7 +125,7 @@ inline auto connectSingleShot(SenderT* sender, SignalT signal,
{
// TODO: when switching to C++20, use std::bind_front() instead
return _impl::connectSingleShot(sender, signal, receiver,
- wrap_in_function(
+ _impl::wrap_in_function(
[receiver, slot](const ArgTs&... args) {
(receiver->*slot)(args...);
}),
diff --git a/lib/util.h b/lib/util.h
index 5bfe6841..c6171b91 100644
--- a/lib/util.h
+++ b/lib/util.h
@@ -219,18 +219,6 @@ template <typename FnT, int ArgN = 0>
using fn_arg_t =
std::tuple_element_t<ArgN, typename function_traits<FnT>::arg_types>;
-// TODO: get rid of it as soon as Apple Clang gets proper deduction guides
-// for std::function<>
-// ...or consider using QtPrivate magic used by QObject::connect()
-// since wrap_in_function() is actually made for qt_connection_util.h
-// ...for inspiration, also check a possible std::not_fn implementation at
-// https://en.cppreference.com/w/cpp/utility/functional/not_fn
-template <typename FnT>
-inline auto wrap_in_function(FnT&& f)
-{
- return typename function_traits<FnT>::function_type(std::forward<FnT>(f));
-}
-
inline constexpr auto operator"" _ls(const char* s, std::size_t size)
{
return QLatin1String(s, int(size));