When I try to invoke the below constructor, passing it a static member function I don't get any errors but when I pass it a non-static member function I get a compilations error:
Constructor
template <class callable, class... arguments>
Timer(int after, duration_type duration, bool async, callable&& f, arguments&&... args)
{
std::function<typename std::result_of<callable(arguments...)>::type()>
task(std::bind(std::forward<callable>(f), std::forward<arguments>(args)...));
}
Invokation
Timer timer(252222, duration_type::milliseconds, true, &MotionAnalyser::ObjectGarbageCollector); // Does not work because it does not point to object too.
Timer timer(252222, duration_type::milliseconds, true, std::bind(this, &MotionAnalyser::ObjectGarbageCollector)); //Should work, but does not?!?!
Error
Error C2039 'type': is not a member of 'std::result_of<callable (void)>'
The invoking object should be a callable type since I over-rode the ()
operator (based on my understanding of callable types).
Aucun commentaire:
Enregistrer un commentaire