jeudi 4 juin 2015

The perfect callback function [duplicate]

This question already has an answer here:

Goal : Obtain a callback function that will take any type of parameters as the callback function's parameters

.h
template <typename F, typename A>
void DelayedCallback(F&& CallbackFunction, A&& Args = NULL);

/

.cpp
void DelayedCallback(F&& CallbackFunction, A&& Args)
{
  //Timer function that received a function pointer to be the "callback"  function
  Timer((std::bind(std::forward<F>(CallbackFunction), std::forward<A>(Args)))())
}

/

DelayedCallback(&HUDExit);

void HUDExit() {}

/

ERROR : DelayedCallback(FName,float,F &&,A &&)' : could not deduce template argument for 'A'

What am I doing wrong? I'm new to most of these concept in c++, more of c# programmer

EDIT : It's not only about the error, I'm pretty sure it's not the only one I am making.

Aucun commentaire:

Enregistrer un commentaire