<?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[Von einem Stream in einen anderen kopieren]]></title><description><![CDATA[<p>Ich habe einen Eingabestream (stringstream) und einen Ausgabestream (beliebiger ostream). Die Eingabe soll komplett auf die Ausgabe kopiert werden und da die Operation recht häufig aufgerufen wird, hab ich mich gefragt, was die schnellste Variante ist.</p>
<ul>
<li>ostream.write()</li>
<li>std::copy() (wahrscheinlich ehr nicht ??)</li>
<li>irgendwas anderes?</li>
</ul>
<pre><code>ostream &lt;&lt; istream.rdbuf()
</code></pre>
<p>hat irgendwie keine Ausgabe bewirkt, obwohl laut Doku <a href="http://en.cppreference.com/w/cpp/io/basic_ostream/operator_ltlt" rel="nofollow">http://en.cppreference.com/w/cpp/io/basic_ostream/operator_ltlt</a> alles soweit i.O. ist.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/314143/von-einem-stream-in-einen-anderen-kopieren</link><generator>RSS for Node</generator><lastBuildDate>Sat, 01 Aug 2026 20:57:49 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/314143.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 21 Feb 2013 18:30:42 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Von einem Stream in einen anderen kopieren on Thu, 21 Feb 2013 18:30:42 GMT]]></title><description><![CDATA[<p>Ich habe einen Eingabestream (stringstream) und einen Ausgabestream (beliebiger ostream). Die Eingabe soll komplett auf die Ausgabe kopiert werden und da die Operation recht häufig aufgerufen wird, hab ich mich gefragt, was die schnellste Variante ist.</p>
<ul>
<li>ostream.write()</li>
<li>std::copy() (wahrscheinlich ehr nicht ??)</li>
<li>irgendwas anderes?</li>
</ul>
<pre><code>ostream &lt;&lt; istream.rdbuf()
</code></pre>
<p>hat irgendwie keine Ausgabe bewirkt, obwohl laut Doku <a href="http://en.cppreference.com/w/cpp/io/basic_ostream/operator_ltlt" rel="nofollow">http://en.cppreference.com/w/cpp/io/basic_ostream/operator_ltlt</a> alles soweit i.O. ist.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2300732</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2300732</guid><dc:creator><![CDATA[iostreamer]]></dc:creator><pubDate>Thu, 21 Feb 2013 18:30:42 GMT</pubDate></item><item><title><![CDATA[Reply to Von einem Stream in einen anderen kopieren on Thu, 21 Feb 2013 18:34:15 GMT]]></title><description><![CDATA[<p>iostreamer schrieb:</p>
<blockquote>
<p>std::copy() (wahrscheinlich ehr nicht ??)</p>
</blockquote>
<p>Du wirst erstaunt sein, das ist gar nicht so langsam.</p>
<pre><code class="language-cpp">std::istreambuf_iterator&lt;char&gt; b(istream), e;
std::copy(b, e, std::ostream_iterator&lt;char&gt;(ostream));
</code></pre>
<p>Ich würde allerdings deine Variante mit rdbuf() verwenden, die sollte eigentlich funktionieren.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2300736</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2300736</guid><dc:creator><![CDATA[wahrscheinlicheherschon]]></dc:creator><pubDate>Thu, 21 Feb 2013 18:34:15 GMT</pubDate></item><item><title><![CDATA[Reply to Von einem Stream in einen anderen kopieren on Thu, 21 Feb 2013 18:36:33 GMT]]></title><description><![CDATA[<p>err, ostream<strong>buf</strong>_iterator</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2300739</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2300739</guid><dc:creator><![CDATA[wahrscheinlicheherschon]]></dc:creator><pubDate>Thu, 21 Feb 2013 18:36:33 GMT</pubDate></item><item><title><![CDATA[Reply to Von einem Stream in einen anderen kopieren on Thu, 21 Feb 2013 18:52:08 GMT]]></title><description><![CDATA[<p>Hallo iostreamer,</p>
<p>ob nachfolgendes die schnellste Variante ist, weiß ich nicht, aber mit die einfachste:</p>
<pre><code>// Ich habe einen Eingabestream (stringstream) ...
    stringstream eingabestream;
    eingabestream &lt;&lt; &quot;egal&quot; &lt;&lt; (4+38) &lt;&lt; &quot; Pi=&quot; &lt;&lt; acos(-1.0) &lt;&lt; endl;
    // ... und einen Ausgabestream (beliebiger ostream). ...
    ostream ausgabestream( cout.rdbuf() );

    // ... Die Eingabe soll komplett auf die Ausgabe kopiert werden
    ausgabestream &lt;&lt; eingabestream.rdbuf();
</code></pre>
<p>Ausgabe:</p>
<pre><code>egal42 Pi=3.14159
</code></pre>
<p>Gruß<br />
Werner</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2300757</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2300757</guid><dc:creator><![CDATA[Werner Salomon]]></dc:creator><pubDate>Thu, 21 Feb 2013 18:52:08 GMT</pubDate></item><item><title><![CDATA[Reply to Von einem Stream in einen anderen kopieren on Thu, 21 Feb 2013 19:23:14 GMT]]></title><description><![CDATA[<p>Danke für die Antworten...</p>
<p>wahrscheinlicheherschon schrieb:</p>
<blockquote>
<p>Du wirst erstaunt sein, das ist gar nicht so langsam.</p>
</blockquote>
<p>Ich habe noch nie in eine STL - Implementation reingeschaut, aber kann es sein, dass die Streamiteratoren dann vieleicht Zugriff auf die interne Repräsentation haben?</p>
<p>wahrscheinlicheherschon schrieb:</p>
<blockquote>
<p>Ich würde allerdings deine Variante mit rdbuf() verwenden, die sollte eigentlich funktionieren.</p>
</blockquote>
<p>Werner Salomon schrieb:</p>
<blockquote>
<p>Hallo iostreamer,</p>
<p>ob nachfolgendes die schnellste Variante ist, weiß ich nicht, aber mit die einfachste:</p>
<pre><code>// Ich habe einen Eingabestream (stringstream) ...
    stringstream eingabestream;
    eingabestream &lt;&lt; &quot;egal&quot; &lt;&lt; (4+38) &lt;&lt; &quot; Pi=&quot; &lt;&lt; acos(-1.0) &lt;&lt; endl;
    // ... und einen Ausgabestream (beliebiger ostream). ...
    ostream ausgabestream( cout.rdbuf() );

    // ... Die Eingabe soll komplett auf die Ausgabe kopiert werden
    ausgabestream &lt;&lt; eingabestream.rdbuf();
</code></pre>
<p>Ausgabe:</p>
<pre><code>egal42 Pi=3.14159
</code></pre>
<p>Gruß<br />
Werner</p>
</blockquote>
<p>Wie gesagt, die rdbuf() - Variante mag nich und mir ist noch nicht klar, warum das so ist ^^</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2300775</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2300775</guid><dc:creator><![CDATA[iostreamer]]></dc:creator><pubDate>Thu, 21 Feb 2013 19:23:14 GMT</pubDate></item><item><title><![CDATA[Reply to Von einem Stream in einen anderen kopieren on Thu, 21 Feb 2013 20:08:55 GMT]]></title><description><![CDATA[<p>iostreamer schrieb:</p>
<blockquote>
<p>Wie gesagt, die rdbuf() - Variante mag nich und mir ist noch nicht klar, warum das so ist ^^</p>
</blockquote>
<p>was bedeutet 'mag nicht' im Detail? - welche Entwicklungsumgebung benutzt Du?</p>
<p>Sollte gehen, <a href="http://www.cplusplus.com/reference/ostream/ostream/operator%3C%3C/" rel="nofollow">ist Standard</a>.</p>
<p>Gruß<br />
Werner</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2300794</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2300794</guid><dc:creator><![CDATA[Werner Salomon]]></dc:creator><pubDate>Thu, 21 Feb 2013 20:08:55 GMT</pubDate></item></channel></rss>