std::forward 为什么要重载 rvalue reference?

2016-10-19 15:14:10 +08:00
 introom

20.2.4p1 参见这里: http://eel.is/c++draft/forward#1 给了这个 signature

template <class t=""> constexpr T&& forward(remove_reference_t<t>&& t) noexcept;

通畅 perfect forwarding 搭配 universal reference ,对于 std::forward<t>而言不都是接受 lvalue 然后根据<t>来 forward 出对应的 lvalue 或是 rvalue 么?也就是使用 20.2.4p1 中的第一个 signature 。

对于第二个 signature ,如果我有 rvalue 了,我又何必多此一举重新 forward 出一个 rvalue 呢?

1096 次点击
所在节点    问与答
0 条回复

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/313880

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX