|
|
|
|
|
by mpyne
4689 days ago
|
|
This is the working code (you have to declare your intention to capture according to the g++ and clang++ error output, and x requires a type in the parameter list): auto sum = 0;
std::for_each(my_vector.begin(), my_vector.end(),
[&sum](unsigned x) { sum += x; });
I'm sure it could be golfed further though. |
|