启用C ++ 14英特尔编译器

时间:2014-11-15 23:02:45

标签: c++ intel c++14

我使用英特尔C ++编译器版本15.0.0.108 Build 20140726并且我无法使用某些C ++ 14功能,例如" decltype(自动),正常功能的返回类型扣除&#34 ;在here

中宣布支持

如果我这样做:

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

然后我收到了这个错误:

  

错误:" auto"这里不允许

我正在使用此编译:

icl /FA /EHs program.cpp

1 个答案:

答案 0 :(得分:2)

您尝试使用的功能称为N3649中的通用(多态)lambda表达式,而您链接的table表示尚未添加支持。但是,您正在使用的认为的功能,“{3}}的”正常功能的decltype(自动),返回类型推导“确实有支持。

通用lambda看起来像:

[](auto a) { return a; }

正常函数的返回类型推导看起来像:

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

以下示例中描述了decltype(auto)的语义:n3638:

  

如果占位符是decltype(auto)类型说明符,则声明   函数的变量类型或返回类型应为   仅占位符。推导出的变量或返回类型的类型是   按照7.1.6.2中的描述确定,就像初始化程序一样   decltype的操作数。 [例如:

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)
     

- 结束示例]