Using std::for_each on call a function with multiple arguments

c++, c++11

Solution

try to use a lambda-function:

std::for_each (mydata.begin(), mydata.end(), [&](double d)
{
  train(d, net);
});

Problem

I did search, but the closest link , among those found, even doesn't match my problem. I have a `std::vector<double> mydata` array. I like to use `for_each` for that `mydata` array in calling a member function. That member function accepts two arguments. One is each element of `mydata` array and another one is a `int*` of another array. I do like ``` ::std::for_each (mydata.begin(), mydata.end(), train(net)); ``` That gives me a compilation error of `train` function does not take one argument. I know how to use for_each if there isn't `int*`. My train function is ``` void train(double const & data, int* d){} ``` How can I make it work? Thanks

Original source

Related problems