views:

396

answers:

3

Is there support for lambda expressions from C++ 0x in Visual Studio 2008 SP1? Example below throws me syntax errors. Is there any '-Cpp0x' flag for compiler or something?

#include <algorithm>
#include <iostream>
#include <ostream>
#include <vector>

using namespace std;

int main() 
{
  vector<int> v;

  for (int i = 0; i < 10; ++i) 
  {
    v.push_back(i);
  }

  for_each(v.begin(), v.end(), [](int n) { cout << n << " "; });
  cout << endl;
}

Thank you in advance.

+2  A: 

See Stackoverflow question #146381

Simply put: no. Visual Studio 2010 will support C++0x to some extent, but I'm unsure if that will include lambda expressions.

DrJokepu
It will. In the CTP version anyway.
Hans Passant
A: 

No, but Visual Studio 2010 CTP does. They demonstrated them at the PDC.

Ferruccio
A: 

Visual studio doesnot support, instead use Boost library.

Vinay