I am trying to make an Event Handler system on my project, and it is already working as expected, but the IDE are accusing an error that I have no idea how to solve. As I said, everything is working, compiling and running normally, but I would like to solve this issue from IntelliSense. Defining Events:
enum class RendererEvents
{
Render,
PostRender
};
struct RenderArgs
{
};
struct PostRenderArgs
{
};
template<typename T> struct EventArgsFn { using type = T; };
template<>
struct EventArgsFn<RendererEvents>
{
using type = std::variant<std::function<void(RenderArgs&)>, std::function<void(PostRenderArgs&)>>;
};
Event Handler:
template<typename T>
class EventProvider
{
public:
/// Subscribe Event with Arguments.
void SubscribeEventArgs(T EventType, typename EventArgsFn<T>::type Fn)
{
m_EventsArgs[EventType].push_back(Fn);
}
private:
/// Events Handler with Arguments.
std::unordered_map<T, std::vector<typename EventArgsFn<T>::type>> m_EventsArgs;
};
Using the Subscribe Event function (where is giving the "error"):
Renderer.SubscribeEventArgs(Graphics::RendererEvents::Render, std::bind(&Teste3, std::placeholders::_1));
The error that are giving:
Cannot convert _Binder<_Unforced, void(*)(Graphics::RenderArgs&), const _Ph<1>&> to parameter type EventArgsFn<Graphics::RendererEvents>::type
Anyone have any idea what's happening if there is some way to suppress this error or solve? Thanks!