From ec4110c63443e29c78fdf0f72af08f5395ec48f7 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Thu, 26 Mar 2020 13:25:09 +0100 Subject: Refactoring around Connection::onSyncSuccess() The method grew large and a bit unwieldy over the years. --- lib/events/event.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'lib/events/event.h') 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 visit(const BaseEventT& event, FnT1&& visitor1, return visit(event, std::forward(visitor2), std::forward(visitors)...); } + +// A facility overload that calls void-returning visit() on each event +// over a range of event pointers +template +inline auto visitEach(RangeT&& events, FnTs&&... visitors) + -> std::enable_if_t, Event>> +{ + for (auto&& evtPtr: events) + visit(*evtPtr, std::forward(visitors)...); +} } // namespace Quotient Q_DECLARE_METATYPE(Quotient::Event*) Q_DECLARE_METATYPE(const Quotient::Event*) -- cgit v1.2.3