Update item23.md

Co-authored-by: Yi Yang <qingfeng.yy@alibaba-inc.com>
This commit is contained in:
猫耳堀川雷鼓 2021-02-27 16:36:17 +08:00 committed by GitHub
parent 2b0d22dfe0
commit bb892d270a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -24,7 +24,7 @@ void f(Widget&& w);
**Item 23: Understand `std::move` and `std::forward`**
为了了解`std::move`和`std::forward`,一种有用的方式是从**它们不做什么**这个角度来了解它们。`std::move`不移动move任何东西`std::forward`也不转发forward任何东西。在运行期里,它们不做任何事情。它们不产生任何可执行代码,一字节也没有。
为了了解`std::move`和`std::forward`,一种有用的方式是从**它们不做什么**这个角度来了解它们。`std::move`不移动move任何东西`std::forward`也不转发forward任何东西。在运行,它们不做任何事情。它们不产生任何可执行代码,一字节也没有。
`std::move`和`std::forward`仅仅是执行转换cast的函数事实上是函数模板。`std::move`无条件的将它的实参转换为右值,而`std::forward`只在特定情况满足时下进行转换。它们就是如此。这样的解释带来了一些新的问题,但是从根本上而言,这就是全部内容。