From df799bf394fa63dc9f39a5b09fe21c16b1cc8a57 Mon Sep 17 00:00:00 2001 From: crupest Date: Mon, 1 Jan 2024 22:20:21 +0800 Subject: NEED TEST: fix compile errors of Event2 and create init test. --- include/cru/common/Event2.h | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'include/cru/common/Event2.h') diff --git a/include/cru/common/Event2.h b/include/cru/common/Event2.h index 5c3a330a..7d7bda82 100644 --- a/include/cru/common/Event2.h +++ b/include/cru/common/Event2.h @@ -51,7 +51,8 @@ class EventHandlerToken { static_assert(is_event2_v, "TEvent2 must be Event2 class."); public: - EventHandlerToken(ObjectResolver event_resolver, int token_value); + EventHandlerToken(ObjectResolver event_resolver, int token_value) + : event_resolver_(std::move(event_resolver)), token_value_(token_value) {} ObjectResolver GetEventResolver() const { return event_resolver_; } int GetTokenValue() const { return token_value_; } @@ -82,17 +83,17 @@ class Event2 : public SelfResolvable> { public: using HandlerToken = EventHandlerToken; using Context = EventContext; - using Handler = std::function; + using Handler = std::function; using SpyOnlyHandler = std::function; template static std::enable_if_t, Handler> WrapAsHandler( TFunc&& handler) { - return Handler([h = std::forward(handler)](Context&) { h(); }); + return Handler([h = std::forward(handler)](Context*) { h(); }); } template - static std::enable_if_t, Handler> + static std::enable_if_t, Handler> WrapAsHandler(TFunc&& handler) { return Handler(std::forward(handler)); } @@ -138,19 +139,19 @@ class Event2 : public SelfResolvable> { TResult Raise() { Context context; - RunInContext(context); + RunInContext(&context); return context.TakeResult(); } TResult Raise(TArgument argument) { Context context(std::move(argument)); - RunInContext(context); + RunInContext(&context); return context.TakeResult(); } TResult Raise(TArgument argument, TResult result) { Context context(std::move(argument), std::move(result)); - RunInContext(context); + RunInContext(&context); return context.TakeResult(); } -- cgit v1.2.3