<?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: Efficient argument passing in C++11, Part 1</title>
	<link>https://codesynthesis.com/~boris/blog//2012/06/19/efficient-argument-passing-cxx11-part1/</link>
	<description>Boris Kolpackov's blog about software</description>
	<pubDate>Sun, 05 Apr 2026 20:49:35 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.2.2</generator>

	<item>
		<title>By: Boris Kolpackov</title>
		<link>https://codesynthesis.com/~boris/blog//2012/06/19/efficient-argument-passing-cxx11-part1/#comment-2103</link>
		<author>Boris Kolpackov</author>
		<pubDate>Wed, 20 Jun 2012 14:01:47 +0000</pubDate>
		<guid>https://codesynthesis.com/~boris/blog//2012/06/19/efficient-argument-passing-cxx11-part1/#comment-2103</guid>
		<description>CM, you are talking about copy elision/[N]RVO optimizations that C++ compilers are allowed (but not required or always capable) to do. So without the move semantics, whether f(g()) will be optimal depends on f() and g()'s implementations, which C++ compiler you are using, optimization level, whether the moon is in the right phase, and who knows what else.

On the other hand, support for the move semantics is mandated by the standard so you can be sure that with a conforming C++11 compiler f(g()) will cost nor more than 2 move constructor calls.</description>
		<content:encoded><![CDATA[<p>CM, you are talking about copy elision/[N]RVO optimizations that C++ compilers are allowed (but not required or always capable) to do. So without the move semantics, whether f(g()) will be optimal depends on f() and g()&#8217;s implementations, which C++ compiler you are using, optimization level, whether the moon is in the right phase, and who knows what else.</p>
<p>On the other hand, support for the move semantics is mandated by the standard so you can be sure that with a conforming C++11 compiler f(g()) will cost nor more than 2 move constructor calls.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: CM</title>
		<link>https://codesynthesis.com/~boris/blog//2012/06/19/efficient-argument-passing-cxx11-part1/#comment-2095</link>
		<author>CM</author>
		<pubDate>Tue, 19 Jun 2012 15:13:12 +0000</pubDate>
		<guid>https://codesynthesis.com/~boris/blog//2012/06/19/efficient-argument-passing-cxx11-part1/#comment-2095</guid>
		<description>Dude, for f(g()) to be efficient g's return type does not need to be moveable. returning value from function does not involve copy (unless your compiler is belongs to a garbage collection) nor does passing rvalue by value.

T g() { return T(...); }
voif f(T v) { ... }

f(g()); is equally efficient in both C++03 and C++11. And it is achieved essentially by wise choice of memory address where given value is going to be constructed. Move-and-init semantic is just a trick that allows you to move value from one address to another explicitly (which is required when std::vector moves stuff around).</description>
		<content:encoded><![CDATA[<p>Dude, for f(g()) to be efficient g&#8217;s return type does not need to be moveable. returning value from function does not involve copy (unless your compiler is belongs to a garbage collection) nor does passing rvalue by value.</p>
<p>T g() { return T(&#8230;); }<br />
voif f(T v) { &#8230; }</p>
<p>f(g()); is equally efficient in both C++03 and C++11. And it is achieved essentially by wise choice of memory address where given value is going to be constructed. Move-and-init semantic is just a trick that allows you to move value from one address to another explicitly (which is required when std::vector moves stuff around).</p>
]]></content:encoded>
	</item>
</channel>
</rss>
