Skip to content

book: typo fix #202

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 6, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion book/zh-cn/03-runtime.md
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ constexpr _Tp&& forward(typename std::remove_reference<_Tp>::type&& __t) noexcep
而 `std::is_lvalue_reference` 用于检查类型推导是否正确,在 `std::forward` 的第二个实现中
检查了接收到的值确实是一个左值,进而体现了坍缩规则。

当 `std::forward` 接受左值时,`_Tp` 被推导为左值,而所以返回值为左值;而当其接受右值时,
当 `std::forward` 接受左值时,`_Tp` 被推导为左值,所以返回值为左值;而当其接受右值时,
`_Tp` 被推导为 右值引用,则基于坍缩规则,返回值便成为了 `&& + &&` 的右值。
可见 `std::forward` 的原理在于巧妙的利用了模板类型推导中产生的差异。

Expand Down