首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

关于编译Lambda时报告返回的为void的异常

2013-10-10 
关于编译Lambda时报告返回的为void的错误这个错误的信息是这样的:a lambda that has been specified to ha

关于编译Lambda时报告返回的为void的错误


这个错误的信息是这样的:

a lambda that has been specified to have a void return type cannot return a value


报告错误的lambda的写法大概是这样:


[](int a, int b){    return a<b;};

至于为什么,看这个解释:

The C++11 standard, §5.1.2/4 states:

If a lambda-expression does not include a trailing-return-type, it is as if the trailing-return-type denotes the following type:

If the compound-statement is of the form { return expression ; } the type of the returned expression after lvalue-to-rvalue conversion (4.1), array-to-pointer conversion (4.2), and function-to-pointer conversion (4.3);

otherwise, void.


热点排行