I am trying to implement some kind of task-class that will be done after some time. Currently I have to implement class, say for example TimeoutTask (needed for the bigger task). In it's body I want to get std::function from template parameters and this function I will call after some extra logic. The problem is that I can't properly "create" this function. But I can call it directly. Where is the problem? (I haven't use templates too much before, just simple ones)
class TimeoutTask
{
public:
template <class Class, class Method, class... arguments>
TimeoutTask(int timeout, Class *obj, Method f, arguments&&... args)
{
// here I get error: error C2059: syntax error : '<tag>::*'
std::function<std::result_of<decltype(obj)(Class)>::type(arguments...)>
task(Class::*Method, obj, std::bind(std::forward<arguments>(args)...));
// here will be some extra logic
// and after this extra logic I want to call 'task' somehow
// but I can call it just by this way:
(obj->*f)(args...);
}
};
And code for creation of this "task":
SomeClass sc;
TimeoutTask testTask(1000, &sc, &SomeClass::someMethod, 101);
Aucun commentaire:
Enregistrer un commentaire