<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.2.2" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
	<title>Comments on: Rvalue reference pitfalls, an update</title>
	<link>https://codesynthesis.com/~boris/blog//2012/03/14/rvalue-reference-pitfalls-update/</link>
	<description>Boris Kolpackov's blog about software</description>
	<pubDate>Wed, 29 Apr 2026 18:48:50 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.2.2</generator>

	<item>
		<title>By: JJ</title>
		<link>https://codesynthesis.com/~boris/blog//2012/03/14/rvalue-reference-pitfalls-update/#comment-1923</link>
		<author>JJ</author>
		<pubDate>Thu, 15 Mar 2012 10:24:19 +0000</pubDate>
		<guid>https://codesynthesis.com/~boris/blog//2012/03/14/rvalue-reference-pitfalls-update/#comment-1923</guid>
		<description>got it. quite tricky indeed. Thx for your answer!</description>
		<content:encoded><![CDATA[<p>got it. quite tricky indeed. Thx for your answer!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Boris Kolpackov</title>
		<link>https://codesynthesis.com/~boris/blog//2012/03/14/rvalue-reference-pitfalls-update/#comment-1922</link>
		<author>Boris Kolpackov</author>
		<pubDate>Thu, 15 Mar 2012 09:21:57 +0000</pubDate>
		<guid>https://codesynthesis.com/~boris/blog//2012/03/14/rvalue-reference-pitfalls-update/#comment-1922</guid>
		<description>JJ, someone asked this question in the reddit's discussion of this post:

http://www.reddit.com/r/cpp/comments/qw786/rvalue_reference_pitfalls_an_update/

I have also provided an answer there.</description>
		<content:encoded><![CDATA[<p>JJ, someone asked this question in the reddit&#8217;s discussion of this post:</p>
<p><a href="http://www.reddit.com/r/cpp/comments/qw786/rvalue_reference_pitfalls_an_update/" rel="nofollow">http://www.reddit.com/r/cpp/comments/qw786/rvalue_reference_pitfalls_an_update/</a></p>
<p>I have also provided an answer there.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Boris Kolpackov</title>
		<link>https://codesynthesis.com/~boris/blog//2012/03/14/rvalue-reference-pitfalls-update/#comment-1921</link>
		<author>Boris Kolpackov</author>
		<pubDate>Thu, 15 Mar 2012 09:19:27 +0000</pubDate>
		<guid>https://codesynthesis.com/~boris/blog//2012/03/14/rvalue-reference-pitfalls-update/#comment-1921</guid>
		<description>Anonymous, no, in this case the second constructor will be selected since its second argument becomes an lvalue reference.</description>
		<content:encoded><![CDATA[<p>Anonymous, no, in this case the second constructor will be selected since its second argument becomes an lvalue reference.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: JJ</title>
		<link>https://codesynthesis.com/~boris/blog//2012/03/14/rvalue-reference-pitfalls-update/#comment-1920</link>
		<author>JJ</author>
		<pubDate>Thu, 15 Mar 2012 09:03:33 +0000</pubDate>
		<guid>https://codesynthesis.com/~boris/blog//2012/03/14/rvalue-reference-pitfalls-update/#comment-1920</guid>
		<description>As for this: "If you are wondering why this is a problem (after all, the first two constructors accomplish essentially the same), consider that while the first constructor’s hypothetical implementation will use a copy constructor to initialize the id, the second constructor will most likely use the move constructor to accomplish the same."

Then, how about having only the second, perfect-forwarding one, and in it using std::forward() instead of std::move()? Wouldn't this solve the issue better than your solution involving enable_if?</description>
		<content:encoded><![CDATA[<p>As for this: &#8220;If you are wondering why this is a problem (after all, the first two constructors accomplish essentially the same), consider that while the first constructor’s hypothetical implementation will use a copy constructor to initialize the id, the second constructor will most likely use the move constructor to accomplish the same.&#8221;</p>
<p>Then, how about having only the second, perfect-forwarding one, and in it using std::forward() instead of std::move()? Wouldn&#8217;t this solve the issue better than your solution involving enable_if?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anonymous</title>
		<link>https://codesynthesis.com/~boris/blog//2012/03/14/rvalue-reference-pitfalls-update/#comment-1919</link>
		<author>Anonymous</author>
		<pubDate>Thu, 15 Mar 2012 08:13:16 +0000</pubDate>
		<guid>https://codesynthesis.com/~boris/blog//2012/03/14/rvalue-reference-pitfalls-update/#comment-1919</guid>
		<description>I have a feeling you meant 'fourth' instead of 'second' here where you refer to the constructor selected.

"Instead of selecting the third constructor, the overload resolution rules select the second because the rvalue reference in its second argument becomes an lvalue reference (see the original post for details on why this happens)."</description>
		<content:encoded><![CDATA[<p>I have a feeling you meant &#8216;fourth&#8217; instead of &#8217;second&#8217; here where you refer to the constructor selected.</p>
<p>&#8220;Instead of selecting the third constructor, the overload resolution rules select the second because the rvalue reference in its second argument becomes an lvalue reference (see the original post for details on why this happens).&#8221;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Boris Kolpackov</title>
		<link>https://codesynthesis.com/~boris/blog//2012/03/14/rvalue-reference-pitfalls-update/#comment-1917</link>
		<author>Boris Kolpackov</author>
		<pubDate>Wed, 14 Mar 2012 18:07:36 +0000</pubDate>
		<guid>https://codesynthesis.com/~boris/blog//2012/03/14/rvalue-reference-pitfalls-update/#comment-1917</guid>
		<description>Yes, that was a type. Fixed, thanks!</description>
		<content:encoded><![CDATA[<p>Yes, that was a type. Fixed, thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: haohaolee</title>
		<link>https://codesynthesis.com/~boris/blog//2012/03/14/rvalue-reference-pitfalls-update/#comment-1916</link>
		<author>haohaolee</author>
		<pubDate>Wed, 14 Mar 2012 15:47:23 +0000</pubDate>
		<guid>https://codesynthesis.com/~boris/blog//2012/03/14/rvalue-reference-pitfalls-update/#comment-1916</guid>
		<description>don't know if this is a typo when you say take its argument by value:
...
  template 
  lazy_shared_ptr (database&#38;, std::shared_ptr&#38; p)
    : p_ (std::move (p))</description>
		<content:encoded><![CDATA[<p>don&#8217;t know if this is a typo when you say take its argument by value:<br />
&#8230;<br />
  template<br />
  lazy_shared_ptr (database&amp;, std::shared_ptr&amp; p)<br />
    : p_ (std::move (p))</p>
]]></content:encoded>
	</item>
</channel>
</rss>
