I am using Visual Studio 2015. My problem is when I run this it compiles and runs no problem:
typedef double Fct(double);
struct Function {
Function(Fct f) { cout << f(1) << endl; };
};
double double_func(double x, double n) { return x + n; }
int main() {
for(int n = 0; n < 50; ++n)
Function e{ [](double x) { return double_func(x,1); } }
}
The thing is I want to have this part:
Function e{ [](double x) { return double_func(x,1); } }
To have a capture argument like this:
typedef double Fct(double);
struct Function {
Function(Fct f) {};
};
double double_func(double x, double n) { return x + n; }
int main() {
for(int n = 0; n < 50; ++n)
Function e{ [n](double x) { return double_func(x,n); } }
}
But I get this error: no instance of constructor "Function::Function" matches the argument list argument types are: (lambda []double (double x)->double)