The following piece of code causes a C2065: 'cout' : undeclared identifier.----------8<-----------------------------------------8<---------------------------#include <iostream>#include <algorithm>int main() { using namespace std; int a[] = { 1, 2, 3 }; for_each(&a[0], &a[0] + 3, [](int i){ cout << i << “\n”; });}----------8<-----------------------------------------8<---------------------------As per ยง5.1.2/3, the closure type of the lambda is declared in main. (Nit: `cout` being a static object and the capture clause being empty guarantees no capture takes place.) However, since the using directive should ideally make `cout` available not only to main but also to the lambda.This issue is not reproducible in Visual Studio 2011 beta.
Visual Studio/Team Foundation Server/.NET Framework Tooling version
Steps to reproduce
Product Language
Operating System
Operating System Language
Actual results
Expected results
Please wait...