6

I am using tbb::parallel_for function which make use of lambdas. I am getting syntax errors with the following code:

void parallel_relax( Class object, std::vector<Vertex *> verList ) {
    tbb::parallel_for (blocked_range<int>(0, verList.size()), [=](const blocked_range<Vertex *>& r) {
        for(Vertex *vit = r.begin(); vit != r.end(); ++vit) {
            Vertex *v = vit;
            object.function(v);
        }
    });
}

Syntax Errors:

syntax error : '['
1>main.cpp(16): error C2143: syntax error : missing ')' before '{'
1>main.cpp(16): error C2143: syntax error : missing ';' before '{'
1>main.cpp(17): error C2065: 'r' : undeclared identifier
1>main.cpp(17): error C2228: left of '.begin' must have class/struct/union
1>          type is ''unknown-type''
1>main.cpp(17): error C2065: 'r' : undeclared identifier
1>main.cpp(17): error C2228: left of '.end' must have class/struct/union
1>          type is ''unknown-type''
1>main.cpp(20): error C2059: syntax error : ')'
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

I think this is the problem with the compiler. How do i get c++11 compiler for visual studio 2010 express edition. Please suggest.

ildjarn
  • 62,044
  • 9
  • 127
  • 211
Sumanth
  • 595
  • 3
  • 14
  • 39

2 Answers2

4

Visual C++ 2010 Express does contain C++11 features, but not all of them. Here is a list of what features it supports (as well as VC++ 2012): http://msdn.microsoft.com/en-ca/library/vstudio/hh567368.aspx

Chris
  • 556
  • 1
  • 4
  • 18
  • How to enable C++11 features? If it is enabled by default, then why is it giving syntax errors? – Sumanth Apr 07 '13 at 20:14
  • 2
    As I said above, not all of them. The list is a little deceiving upon first glance, but further down you can see that support for lambdas in VC10 is only partial, which is why you're getting the syntax error. – Chris Apr 08 '13 at 01:55
  • This link seems to list only VS2012,13,15 – slyy2048 Aug 23 '16 at 00:48
3

To get C++11 features you should use the latest version, Visual Studio 2012.

From C++11 Features (Modern C++):

Visual C++ 2010 implemented many features in the C++0x core language specification, which was the precursor to C++11, and Visual C++ in Visual Studio 2012 expands on that to include many C++11 features.

chue x
  • 18,573
  • 7
  • 56
  • 70