<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[bringen hier rvalues was?]]></title><description><![CDATA[<p>Folgende Situation:</p>
<pre><code class="language-cpp">vector&lt;T&gt; gen()
{
  vector&lt;T&gt; v;
 // fülle v;
}

int main()
{
  vector&lt;T&gt; vec = gen();
}
</code></pre>
<p>Kann ich da mit rvalues was optimieren?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/303028/bringen-hier-rvalues-was</link><generator>RSS for Node</generator><lastBuildDate>Tue, 11 Aug 2026 00:01:42 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/303028.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 03 May 2012 18:52:15 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to bringen hier rvalues was? on Thu, 03 May 2012 18:52:15 GMT]]></title><description><![CDATA[<p>Folgende Situation:</p>
<pre><code class="language-cpp">vector&lt;T&gt; gen()
{
  vector&lt;T&gt; v;
 // fülle v;
}

int main()
{
  vector&lt;T&gt; vec = gen();
}
</code></pre>
<p>Kann ich da mit rvalues was optimieren?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2208035</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2208035</guid><dc:creator><![CDATA[ddfsf]]></dc:creator><pubDate>Thu, 03 May 2012 18:52:15 GMT</pubDate></item><item><title><![CDATA[Reply to bringen hier rvalues was? on Thu, 03 May 2012 18:56:51 GMT]]></title><description><![CDATA[<p>Ja:</p>
<pre><code class="language-cpp">vector&lt;T&gt; gen() 
{ 
  vector&lt;T&gt; v; 
 // fülle v; 
  return move(v);
} 

int main() 
{ 
  vector&lt;T&gt; vec = gen(); 
}
</code></pre>
<p><a href="http://cpp-next.com/archive/2009/08/want-speed-pass-by-value/" rel="nofollow">http://cpp-next.com/archive/2009/08/want-speed-pass-by-value/</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2208036</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2208036</guid><dc:creator><![CDATA[dot]]></dc:creator><pubDate>Thu, 03 May 2012 18:56:51 GMT</pubDate></item><item><title><![CDATA[Reply to bringen hier rvalues was? on Thu, 03 May 2012 18:56:14 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/6496">@dot</a><br />
Nein. Der vector wird da auch ohne cast gemoved.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2208038</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2208038</guid><dc:creator><![CDATA[cooky451]]></dc:creator><pubDate>Thu, 03 May 2012 18:56:14 GMT</pubDate></item><item><title><![CDATA[Reply to bringen hier rvalues was? on Thu, 03 May 2012 18:57:23 GMT]]></title><description><![CDATA[<p>cooky451 schrieb:</p>
<blockquote>
<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/6496">@dot</a><br />
Nein. Der vector wird da auch ohne cast gemoved.</p>
</blockquote>
<p>Huch? Was für ein Cast und wieso sollte er da von selber gemoved werden, der Vektor in gen() ist kein rvalue!?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2208040</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2208040</guid><dc:creator><![CDATA[dot]]></dc:creator><pubDate>Thu, 03 May 2012 18:57:23 GMT</pubDate></item><item><title><![CDATA[Reply to bringen hier rvalues was? on Thu, 03 May 2012 18:58:11 GMT]]></title><description><![CDATA[<p>Der Code ist schon optimiert dank der copy elision.<br />
Ein explizites move würde den Code hier nur verlangsamen.</p>
<p>Im Code von dot zum Beispiel wird 1 Move-Construktor aufgerufen, in deinem keiner.</p>
<p>Ich frage mich echt, woher die fixe Idee kommt, jeden Rückgabewert moven zu müssen. Das ist einfach immer falsch.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2208041</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2208041</guid><dc:creator><![CDATA[oinknll]]></dc:creator><pubDate>Thu, 03 May 2012 18:58:11 GMT</pubDate></item><item><title><![CDATA[Reply to bringen hier rvalues was? on Thu, 03 May 2012 19:00:15 GMT]]></title><description><![CDATA[<p>cooky451 schrieb:</p>
<blockquote>
<p>Nein. Der vector wird da auch ohne cast gemoved.</p>
</blockquote>
<p>Der wird nicht mal gemoved, der wird gleich passend erstellt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2208042</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2208042</guid><dc:creator><![CDATA[oinknll]]></dc:creator><pubDate>Thu, 03 May 2012 19:00:15 GMT</pubDate></item><item><title><![CDATA[Reply to bringen hier rvalues was? on Thu, 03 May 2012 19:08:35 GMT]]></title><description><![CDATA[<p>oinknll schrieb:</p>
<blockquote>
<p>cooky451 schrieb:</p>
<blockquote>
<p>Nein. Der vector wird da auch ohne cast gemoved.</p>
</blockquote>
<p>Der wird nicht mal gemoved, der wird gleich passend erstellt.</p>
</blockquote>
<p>Das ist eine nicht garantierte Optimierung. Aber die meisten Compiler werden das wohl schaffen, das stimmt.</p>
<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/6496">@dot</a><br />
move() ist ein Cast auf T&amp;&amp;. Und er wird gemoved. (Sofern nicht optimiert wird.)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2208048</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2208048</guid><dc:creator><![CDATA[cooky451]]></dc:creator><pubDate>Thu, 03 May 2012 19:08:35 GMT</pubDate></item><item><title><![CDATA[Reply to bringen hier rvalues was? on Thu, 03 May 2012 19:09:34 GMT]]></title><description><![CDATA[<p>cooky451 schrieb:</p>
<blockquote>
<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/6496">@dot</a><br />
move() ist ein Cast auf T&amp;&amp;. Und er wird gemoved. (Sofern nicht optimiert wird.)</p>
</blockquote>
<p>Ok, gut, das meinstest du also mit Cast. Wie genau der Compiler das lvalue von selber moven soll, ist mir allerdings noch nicht klar...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2208049</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2208049</guid><dc:creator><![CDATA[dot]]></dc:creator><pubDate>Thu, 03 May 2012 19:09:34 GMT</pubDate></item><item><title><![CDATA[Reply to bringen hier rvalues was? on Thu, 03 May 2012 19:12:40 GMT]]></title><description><![CDATA[<p>dot schrieb:</p>
<blockquote>
<p>Wie genau der Compiler das lvalue von selber moven soll, ist mir allerdings noch nicht klar...</p>
</blockquote>
<p>Im return Statement sind Funktionslokale Variablen rvalues und werden deshalb gemoved. Ich weiß gerade nicht genau wo das im Standard steht, bin mir aber ziemlich sicher. Kannste ja gern ausprobieren.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2208050</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2208050</guid><dc:creator><![CDATA[cooky451]]></dc:creator><pubDate>Thu, 03 May 2012 19:12:40 GMT</pubDate></item><item><title><![CDATA[Reply to bringen hier rvalues was? on Thu, 03 May 2012 19:14:55 GMT]]></title><description><![CDATA[<p>dot schrieb:</p>
<blockquote>
<p>Ja:</p>
<pre><code class="language-cpp">vector&lt;T&gt; gen() 
{ 
  vector&lt;T&gt; v; 
 // fülle v; 
  return move(v);
} 

int main() 
{ 
  vector&lt;T&gt; vec = gen(); 
}
</code></pre>
<p><a href="http://cpp-next.com/archive/2009/08/want-speed-pass-by-value/" rel="nofollow">http://cpp-next.com/archive/2009/08/want-speed-pass-by-value/</a></p>
</blockquote>
<h1></h1>
<p>müsste das nicht</p>
<pre><code class="language-cpp">vector&lt;T&gt;&amp;&amp; gen() 
{ 
  vector&lt;T&gt; v; 
 // fülle v; 
  return move(v);
} 

int main() 
{ 
  vector&lt;T&gt; vec = gen(); 
}
</code></pre>
<p>heißen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2208052</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2208052</guid><dc:creator><![CDATA[dfdsd]]></dc:creator><pubDate>Thu, 03 May 2012 19:14:55 GMT</pubDate></item><item><title><![CDATA[Reply to bringen hier rvalues was? on Thu, 03 May 2012 19:16:42 GMT]]></title><description><![CDATA[<blockquote>
<blockquote>
<blockquote>
<blockquote>
<p><strong>RVALUE REFERENZEN SIND AUCH NUR REFERENZEN, REFERENZEN AUF LOKALE VARIABLEN ZURÜCKGEBEN IST BÖSE.</strong></p>
</blockquote>
</blockquote>
</blockquote>
</blockquote>
<p>Ist das so schwer zu verstehen? <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /> <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /> <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2208053</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2208053</guid><dc:creator><![CDATA[314159265358979]]></dc:creator><pubDate>Thu, 03 May 2012 19:16:42 GMT</pubDate></item><item><title><![CDATA[Reply to bringen hier rvalues was? on Thu, 03 May 2012 19:16:50 GMT]]></title><description><![CDATA[<p>dfdsd schrieb:</p>
<blockquote>
<p>müsste das nicht</p>
<pre><code class="language-cpp">vector&lt;T&gt;&amp;&amp;
</code></pre>
<p>heißen?</p>
</blockquote>
<p>Nein, das wäre eine danling reference. Rvalue-Referenzen sind auch nur Referenzen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2208054</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2208054</guid><dc:creator><![CDATA[cooky451]]></dc:creator><pubDate>Thu, 03 May 2012 19:16:50 GMT</pubDate></item><item><title><![CDATA[Reply to bringen hier rvalues was? on Thu, 03 May 2012 21:15:26 GMT]]></title><description><![CDATA[<p>cooky451 schrieb:</p>
<blockquote>
<p>dot schrieb:</p>
<blockquote>
<p>Wie genau der Compiler das lvalue von selber moven soll, ist mir allerdings noch nicht klar...</p>
</blockquote>
<p>Im return Statement sind Funktionslokale Variablen rvalues und werden deshalb gemoved. Ich weiß gerade nicht genau wo das im Standard steht, bin mir aber ziemlich sicher. Kannste ja gern ausprobieren.</p>
</blockquote>
<p>Etwas zu grob formuliert. Lvalues, die für copy elision in Frage kommen (NRVO) oder kämen, wenn es sich nicht gerade um Funktionsparameter handeln würde, werden zunächst so behandelt als ob es sich um rvalues handeln würde. Sofern die Überladungsauflösung allerdings fehlschlägt oder die gewählte Überladung keine rvalue-Referenz als Parameter hat (z.B. weil die betreffende Klasse nur einen Copy- aber keinen Move-Konstruktor hat), wird der Ausdruck normal als lvalue behandelt.<br />
Alle anderen lvalue-Ausdrücke bleiben auch solche.<br />
12.8/32</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2208087</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2208087</guid><dc:creator><![CDATA[camper]]></dc:creator><pubDate>Thu, 03 May 2012 21:15:26 GMT</pubDate></item></channel></rss>