From 08a3c52134cfc3458a86c2fc238f9a20a04e0c3c Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Sun, 8 Jul 2018 14:50:54 +0900 Subject: Use constexpr functions instead of variables MSVC struggles with template variables... --- lib/events/event.h | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'lib/events/event.h') diff --git a/lib/events/event.h b/lib/events/event.h index 7fd9868d..06cad5d1 100644 --- a/lib/events/event.h +++ b/lib/events/event.h @@ -308,16 +308,22 @@ namespace QMatrixClient } template - constexpr auto is_event_v = std::is_base_of>::value; + constexpr auto is_event() + { + return std::is_base_of>::value; + } template - constexpr auto needs_cast_v = !std::is_convertible>::value; + constexpr auto needs_cast() + { + return !std::is_convertible>::value; + } // A single type-specific void visitor template inline std::enable_if_t< - is_event_v && needs_cast_v && + is_event() && needs_cast() && std::is_void>::value> visit(const BaseEventT& event, FnT&& visitor) { @@ -330,7 +336,7 @@ namespace QMatrixClient template inline std::enable_if_t< - is_event_v && needs_cast_v, + is_event() && needs_cast(), fn_return_t> // non-voidness is guarded by defaultValue type visit(const BaseEventT& event, FnT&& visitor, fn_return_t&& defaultValue = {}) @@ -344,7 +350,7 @@ namespace QMatrixClient // A chain of 2 or more visitors template inline - std::enable_if_t, fn_return_t> + std::enable_if_t(), fn_return_t> visit(const BaseEventT& event, FnT1&& visitor1, FnT2&& visitor2, FnTs&&... visitors) { -- cgit v1.2.3