Nested for_each with lambda not possible?
- by Ela782
The following code does not compile in VS2012, it gives
error C2064: term does not evaluate to a function taking 1 arguments
on the line of the second for_each (line 4 below).
vector<string> v1;
for_each(begin(v1), end(v1), [](string s1) {
vector<string> v2;
for_each(begin(v2), end(v2), [](string s2) {
cout << "...";
});
});
I found some related stuff like http://connect.microsoft.com/VisualStudio/feedback/details/560907/capturing-variables-in-nested-lambdas which shows a bug (they are doing something different) but on the other hand that shows that what I print above should be possible.
What's wrong with the above code?