简体   繁体   中英

Enable C++14 Intel Compiler

I'm using Intel C++ Compiler version 15.0.0.108 Build 20140726 and I can't use some C++14 features like "decltype(auto), return type deduction for normal functions" declared support in here

If I do something like:

std::for_each(vector.begin(), vector.end(), [] (auto value) {});

Then I got this error:

error: "auto" is not allowed here

I'm compiling using this:

icl /FA /EHs program.cpp

The feature you're trying to use is called a generic (polymorphic) lambda expression from N3649 and the table you linked shows that support has not been added yet. However, the feature(s) you think you're using, "decltype(auto), return type deduction for normal functions" from N3638 do have support.

A generic lambda looks like:

[](auto a) { return a; }

Return type deduction for normal functions looks like:

auto func() { return 42; } // deduced to be int

The semantics for decltype(auto) are described in the following example from n3638:

If the placeholder is the decltype(auto) type-specifier, the declared type of the variable or return type of the function shall be the placeholder alone. The type deduced for the variable or return type is determined as described in 7.1.6.2, as though the initializer had been the operand of the decltype. [ Example:

 int i; int&& f(); auto x3a = i; // decltype(x3a) is int decltype(auto) x3d = i; // decltype(x3d) is int auto x4a = (i); // decltype(x4a) is int decltype(auto) x4d = (i); // decltype(x4d) is int& auto x5a = f(); // decltype(x5a) is int decltype(auto) x5d = f(); // decltype(x5d) is int&& auto x6a = { 1, 2 }; // decltype(x6a) is std::initializer_list<int> decltype(auto) x6d = { 1, 2 }; // error, { 1, 2 } is not an expression auto *x7a = &i; // decltype(x7a) is int* decltype(auto)*x7d = &i; // error, declared type is not plain decltype(auto) 

— end example ]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM