So I am writing an interface class where on of the functions takes a function-callback as a parameter.
Usually I just write this as follows:
template <typename functor>
void some_fn(functor & callback)
{
callback();
}
But in my interface it would be virtual:
template <typename functor>
virtual void some_fn(functor & callback) = 0;
This gives the error: template may not be virtual
. So fair enough.
Now, I think I can get around this by using std::function (and therefore it does not need to be a template), but I just find std::function more of a pain in the arse. So I am wandering if there is some other method to have a virtual function that takes a callback as a parameter?
Aucun commentaire:
Enregistrer un commentaire