I'm learning variadic templates in C++11. How can I call test.finder as a functional argument of test.var_finder ?
#include <functional>
#include <iostream>
class c_test {
public:
double finder(double a, double b = 0) {
return a + b;
};
template<typename... Args>
double var_finder(double c, Args... args, std::function<double (Args... args)> func) {
return c * func(args...);
};
};
int main () {
c_test test;
std::cout << test.var_finder(0.1, 2, test.finder) << std::endl;
return 0;
}
My expected result is 0.1 * (2 + 0) = 0.2.
Aucun commentaire:
Enregistrer un commentaire