mirror of
https://github.com/CnTransGroup/EffectiveModernCppChinese.git
synced 2025-02-06 17:20:44 +08:00
deploy: 25a0569cde
This commit is contained in:
parent
52fd161dc8
commit
37e327eba5
@ -230,7 +230,7 @@ T&& forward(remove_reference_t<T>& param)
|
||||
<pre><code class="language-cpp">Widget widgetFactory(); //返回右值的函数
|
||||
Widget w; //一个变量(左值)
|
||||
func(w); //用左值调用func;T被推导为Widget&
|
||||
func(widgetFactory()); //用又值调用func;T被推导为Widget
|
||||
func(widgetFactory()); //用右值调用func;T被推导为Widget
|
||||
</code></pre>
|
||||
<p>在auto的写法中,规则是类似的。声明</p>
|
||||
<pre><code class="language-cpp">auto&& w1 = w;
|
||||
|
@ -4146,7 +4146,7 @@ T&& forward(remove_reference_t<T>& param)
|
||||
<pre><code class="language-cpp">Widget widgetFactory(); //返回右值的函数
|
||||
Widget w; //一个变量(左值)
|
||||
func(w); //用左值调用func;T被推导为Widget&
|
||||
func(widgetFactory()); //用又值调用func;T被推导为Widget
|
||||
func(widgetFactory()); //用右值调用func;T被推导为Widget
|
||||
</code></pre>
|
||||
<p>在auto的写法中,规则是类似的。声明</p>
|
||||
<pre><code class="language-cpp">auto&& w1 = w;
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user