I'm trying to create a object that can be given a function and its parameters to his constructor. This class will then call the given function inside a lambda that is instead passed to a thread. Something along the lines of
class worker {
public:
template <class Fn, class... Args>
explicit worker(Fn f, Args ... args) {
t = std::thread([&]() -> void {
f(args...);
}
});
}
};
But I get the following error
error: parameter packs not expanded with '...': f(args...);
What am I doing wrong here? Any help would be appreciated.
Aucun commentaire:
Enregistrer un commentaire