aboutsummaryrefslogtreecommitdiff
path: root/lib/events/event.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/events/event.h')
-rw-r--r--lib/events/event.h38
1 files changed, 15 insertions, 23 deletions
diff --git a/lib/events/event.h b/lib/events/event.h
index 12903274..7fd9868d 100644
--- a/lib/events/event.h
+++ b/lib/events/event.h
@@ -315,10 +315,11 @@ namespace QMatrixClient
// A single type-specific void visitor
template <typename BaseEventT, typename FnT>
- inline auto visit(const BaseEventT& event, FnT&& visitor)
- -> std::enable_if_t<
- is_event_v<BaseEventT> && needs_cast_v<BaseEventT, FnT> &&
- std::is_void<fn_return_t<FnT>>::value>
+ inline
+ std::enable_if_t<
+ is_event_v<BaseEventT> && needs_cast_v<BaseEventT, FnT> &&
+ std::is_void<fn_return_t<FnT>>::value>
+ visit(const BaseEventT& event, FnT&& visitor)
{
using event_type = fn_arg_t<FnT>;
if (is<event_type>(event))
@@ -327,11 +328,12 @@ namespace QMatrixClient
// A single type-specific non-void visitor with an optional default value
template <typename BaseEventT, typename FnT>
- inline auto visit(const BaseEventT& event, FnT&& visitor,
- fn_return_t<FnT>&& defaultValue = {})
- -> std::enable_if_t<
- is_event_v<BaseEventT> && needs_cast_v<BaseEventT, FnT>,
- fn_return_t<FnT>> // non-voidness is guarded by defaultValue type
+ inline
+ std::enable_if_t<
+ is_event_v<BaseEventT> && needs_cast_v<BaseEventT, FnT>,
+ fn_return_t<FnT>> // non-voidness is guarded by defaultValue type
+ visit(const BaseEventT& event, FnT&& visitor,
+ fn_return_t<FnT>&& defaultValue = {})
{
using event_type = fn_arg_t<FnT>;
if (is<event_type>(event))
@@ -341,9 +343,10 @@ namespace QMatrixClient
// A chain of 2 or more visitors
template <typename BaseEventT, typename FnT1, typename FnT2, typename... FnTs>
- inline auto visit(const BaseEventT& event, FnT1&& visitor1,
- FnT2&& visitor2, FnTs&&... visitors)
- -> std::enable_if_t<is_event_v<BaseEventT>, fn_return_t<FnT1>>
+ inline
+ std::enable_if_t<is_event_v<BaseEventT>, fn_return_t<FnT1>>
+ visit(const BaseEventT& event, FnT1&& visitor1, FnT2&& visitor2,
+ FnTs&&... visitors)
{
using event_type1 = fn_arg_t<FnT1>;
if (is<event_type1>(event))
@@ -351,17 +354,6 @@ namespace QMatrixClient
return visit(event, std::forward<FnT2>(visitor2),
std::forward<FnTs>(visitors)...);
}
-
- // An adaptor accepting a pointer-like object instead of an event
- template <typename EventHolderT, typename... FnTs>
- inline auto visit(const EventHolderT& e, FnTs&&... visitors)
- -> decltype(visit(*e, std::forward<FnTs>(visitors)...))
- {
- using return_type = decltype(visit(*e, std::forward<FnTs>(visitors)...));
- if (e)
- return visit(*e, std::forward<FnTs>(visitors)...);
- return return_type();
- }
} // namespace QMatrixClient
Q_DECLARE_METATYPE(QMatrixClient::Event*)
Q_DECLARE_METATYPE(const QMatrixClient::Event*)