Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Pallav_G_Intel
Employee
38 Views

ICC 12.1.0e compile failure with lambda function.

Hi,

Consider the code in this example:

test.cpp


This code compiles/run fine on GCC 4.6.2, but on ICC 12.1.0e, I get the following error:

$ icpc test.cpp
test.cpp(22): error: expected an expression
for_each(idx.begin(), idx.end(), [&m_vec](int x) { cout << m_vec << "\\n"; });
^

compilation aborted for test.cpp (code 2)

The [&m_vec] should be [this]. It seems like there is compatibility issues between ICC/GNU GCC on this. The standard seems to say [this] is correct. Perhaps this issue could be resolved to make ICC compatible with GCC?

Thanks.

0 Kudos
1 Reply
SKost
Valued Contributor II
38 Views

...
for_each( idx.begin(), idx.end(), [&m_vec](int x) { cout << m_vec << "\n"; } );
...

Are you sure thatthe Last term of 'for_each'statement can't be evaluated bythe C++ compilerto a function with one argument?