aboutsummaryrefslogtreecommitdiff
path: root/lib/events/event.h
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2020-03-26 13:25:09 +0100
committerKitsune Ral <Kitsune-Ral@users.sf.net>2020-03-26 13:25:09 +0100
commitec4110c63443e29c78fdf0f72af08f5395ec48f7 (patch)
tree9231a07da3124c70758ffa370be8c3ebb8eca3f7 /lib/events/event.h
parent3ba2acce470407854bb38b2633675e916a51a904 (diff)
downloadlibquotient-ec4110c63443e29c78fdf0f72af08f5395ec48f7.tar.gz
libquotient-ec4110c63443e29c78fdf0f72af08f5395ec48f7.zip
Refactoring around Connection::onSyncSuccess()
The method grew large and a bit unwieldy over the years.
Diffstat (limited to 'lib/events/event.h')
-rw-r--r--lib/events/event.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/events/event.h b/lib/events/event.h
index f985ae92..6c8961ad 100644
--- a/lib/events/event.h
+++ b/lib/events/event.h
@@ -377,6 +377,17 @@ inline fn_return_t<FnT1> visit(const BaseEventT& event, FnT1&& visitor1,
return visit(event, std::forward<FnT2>(visitor2),
std::forward<FnTs>(visitors)...);
}
+
+// A facility overload that calls void-returning visit() on each event
+// over a range of event pointers
+template <typename RangeT, typename... FnTs>
+inline auto visitEach(RangeT&& events, FnTs&&... visitors)
+ -> std::enable_if_t<std::is_convertible_v<
+ std::decay_t<decltype(**events.begin())>, Event>>
+{
+ for (auto&& evtPtr: events)
+ visit(*evtPtr, std::forward<FnTs>(visitors)...);
+}
} // namespace Quotient
Q_DECLARE_METATYPE(Quotient::Event*)
Q_DECLARE_METATYPE(const Quotient::Event*)