From 3f7ba739a4f245e51554f4b9fa5f51be4edee678 Mon Sep 17 00:00:00 2001 From: Gordon McCann Date: Sun, 9 Jan 2022 17:13:09 -0500 Subject: [PATCH] Replaced std::bind and std::function to reduce code overhead. Simplified EventDispatcher templating --- Navigator/src/Navigator/Events/Event.h | 9 +++------ Navigator/src/Navigator/NavCore.h | 2 +- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/Navigator/src/Navigator/Events/Event.h b/Navigator/src/Navigator/Events/Event.h index 7e7b303..3a2413d 100644 --- a/Navigator/src/Navigator/Events/Event.h +++ b/Navigator/src/Navigator/Events/Event.h @@ -47,21 +47,18 @@ namespace Navigator { class NAV_API EventDispatcher { - template - using EventFunc = std::function; - public: EventDispatcher(Event& e) : m_event(e) { } - template - bool Dispatch(EventFunc function) + template + bool Dispatch(const F& function) { if(m_event.GetEventType() == T::GetStaticType()) { - m_event.handledFlag = function(*(T*)&m_event); + m_event.handledFlag = function(static_cast(m_event)); return true; } else diff --git a/Navigator/src/Navigator/NavCore.h b/Navigator/src/Navigator/NavCore.h index 7a7ea64..dedd18b 100644 --- a/Navigator/src/Navigator/NavCore.h +++ b/Navigator/src/Navigator/NavCore.h @@ -16,6 +16,6 @@ //Bit field setter #define BIT(x) (1< decltype(auto) { return this->x(std::forward(args)...); } #endif