Я не знаю, как вызвать функцию call
.
Это шаблонный класс с шаблонным вызовом функции. Но как я могу использовать этот код?
#include <iostream>
#include <conio.h>
#include <functional>
template <typename Result> class Imp {
template <typename ...Args> int call(std::function<Result(Args...)> func, Args... args) {
return 0;
}
};
int f(double a, double b) {
return (int)a+b;
}
int main() {
Imp<int> a;
a.call<double, double>(f, 1., 1.); //!
}
error C2784: 'int Imp<int>::call(std::function<Result(Args...)>,Args...)' : could not deduce template argument for 'overloaded function type' from 'overloaded function type'
with
[
Result=int
]
: see declaration of 'Imp<int>::call'