Skip to content

Commit

Permalink
修改 F.48
Browse files Browse the repository at this point in the history
  • Loading branch information
Mq-b committed Feb 3, 2024
1 parent c11ea34 commit 9d46db5
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion C++CoreGuidelines/第4章-函数.md
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,7 @@ int main(){

在编译时,GCC 编译器会立即抱怨对临时对象的引用。准确地说,临时对象的生存期随着整个表达式 `auto myInt = returnRvalueReference();` 的结束而结束。

> **在函数调用中绑定到函数形参的临时量,存在到含这次函数调用的全表达式结尾为止:如果函数返回一个生命长于全表达式的引用,那么它会成为悬垂引用**
> **return 语句中绑定到函数返回值的临时量不会被延续:它在返回表达式的末尾立即销毁。这种 return 语句始终返回悬垂引用**
```text
<source>: In function 'int&& returnRvalueReference()':
Expand Down

0 comments on commit 9d46db5

Please sign in to comment.