Nested for_each with lambda not possible?

Posted by Ela782 on Stack Overflow See other posts from Stack Overflow or by Ela782
Published on 2013-06-27T16:18:27Z Indexed on 2013/06/27 16:21 UTC
Read the original article Hit count: 176

Filed under:
|
|
|
|

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?

© Stack Overflow or respective owner

Related posts about c++

Related posts about visual-c++