so the basics of the program is that Application.cpp will pass a function (from any class) to the EventDispatcher in EventDispatcher.h by passing a function to call into the SubsticbeToEvent function in the EventDispatcher.h. I have managed to set up the function deleration in EventDispatcher.h without any issues:
static void SubscribeToEvent(size_t _eventID, const std::function<void(Event&)> _func) {}
However I'm unsure how to pass the function into SubscribeToEvent
This is the function, remember it is in a class called Application
void HelloWorld(Engine::Event& e)
{
Engine::Logger::Debug("Hello World");
}
This is how I am calling SubscribeToEvent
Engine::EventDispatcher::SubscribeToEvent(e, Application::HelloWorld);
This is the error I am receiving:
no sutible constructor exists to convert from "void (Engine::Event& e)" to "std::function<void(Engine::Event&)".
Through research I have tried the following:
Engine::EventDispatcher::SubscribeToEvent(e, { Application::HelloWorld });
Engine::EventDispatcher::SubscribeToEvent(e, [] { Application::HelloWorld });
Engine::EventDispatcher::SubscribeToEvent(e, [&] { Application::HelloWorld });
Engine::EventDispatcher::SubscribeToEvent(e, { Application::HelloWorld(Event& e });
(and without the variable name, only the type)
Engine::EventDispatcher::SubscribeToEvent(e, [] { Application::HelloWorld(Event& e });
(and without the variable name, only the type)
Engine::EventDispatcher::SubscribeToEvent(e, [&] { Application::HelloWorld(Event& e });
(and without the variable name, only the type)
I'm unsure what is wrong, any suggestions would be great, Thanks.