我不小心把我的函数定义的左大括号放在return语句之后
int id(int k) return k; { }
Run Code Online (Sandbox Code Playgroud)
但GCC回答了一个奇怪的错误消息
错误:不再支持命名返回值
任何人都可以解释这个奇怪的功能可能是什么?我从来没有听说过.
Ste*_*end 39
请参阅此处 - 通过在函数头中显式定义命名返回值来实现早期NRVO.
此处添加了对没有此扩展的NRVO的原生支持- GCC 3.1 Release Series.
简要剪切和粘贴上下文:
G++ now supports the "named return value optimization": for code like
Run Code Online (Sandbox Code Playgroud)A f () { A a; ... return a; }G++ will allocate a in the return value slot, so that the return becomes a no-op. For this to work, all return statements in the function must return the same variable.
| 归档时间: |
|
| 查看次数: |
8284 次 |
| 最近记录: |