diff options
-rw-r--r-- | lib/qt_connection_util.h | 17 | ||||
-rw-r--r-- | lib/util.h | 12 |
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...); }), @@ -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)); |