I want to define a member function which can be returned the std::function object of another member function. In general, it is very easily. But if that member function is defined by parameter packs, I don't know how to do it.
I wrote some code as follow,
class Example {
pubilc:
template<typename... Args>
double getSome(Args.. args) {
// do something
}
template<typename... Args>
std::function<double(Args...)> getSomeFun() {
return std::bind(&Example::getSome<Args...>, this);
}
};
That's look like correctly, unfortunate. When I call getSetArgsFunction() at main() method, I get a lot of error information. At main() method, my code as follow,
int main() {
Example e;
e.getSomeFun()(1.0, 2.0, 3.0);
}
I try to compile it, but gcc print some errors as follow,
error: no match for call to ‘(std::function<double()>) (double, double, double)’
So, what should we do?
Aucun commentaire:
Enregistrer un commentaire