<?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[Ausgabe von STL-Containern mittels &amp;lt;&amp;lt;]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich würde gerne STL-Container mittels &lt;&lt; ausgeben. Also für z.B. vector und map ungefähr so:</p>
<pre><code class="language-cpp">template&lt;class T&gt; ostream&amp; operator&lt;&lt;(ostream&amp; s, const vector&lt;T&gt;&amp; v)
{
	for (typename vector&lt;T&gt;::const_iterator it = v.begin(); it != v.end(); ++it)
		s &lt;&lt; *it &lt;&lt; &quot; &quot;;
	return s;
}

template&lt;class K, class V&gt; ostream&amp; operator&lt;&lt;(ostream&amp; s, const map&lt;K, V&gt;&amp; mp)
{
	for (typename map&lt;K, V&gt;::const_iterator it = mp.begin(); it != mp.end(); ++it)
		s &lt;&lt; (*it).first &lt;&lt; &quot; =&gt; &quot; &lt;&lt; (*it).second &lt;&lt; &quot;   &quot;;
	return s;
}
</code></pre>
<p>Inzwischen frage ich mich allerdings, ob es das nicht in irgendeiner Bibliothek gibt; in STL und Boost war ich aber nicht fündig.</p>
<p>Weiss irgendwer was dazu?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/226217/ausgabe-von-stl-containern-mittels-lt-lt</link><generator>RSS for Node</generator><lastBuildDate>Thu, 01 Oct 2026 01:18:03 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/226217.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 30 Oct 2008 18:18:36 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Ausgabe von STL-Containern mittels &amp;lt;&amp;lt; on Thu, 30 Oct 2008 18:18:36 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich würde gerne STL-Container mittels &lt;&lt; ausgeben. Also für z.B. vector und map ungefähr so:</p>
<pre><code class="language-cpp">template&lt;class T&gt; ostream&amp; operator&lt;&lt;(ostream&amp; s, const vector&lt;T&gt;&amp; v)
{
	for (typename vector&lt;T&gt;::const_iterator it = v.begin(); it != v.end(); ++it)
		s &lt;&lt; *it &lt;&lt; &quot; &quot;;
	return s;
}

template&lt;class K, class V&gt; ostream&amp; operator&lt;&lt;(ostream&amp; s, const map&lt;K, V&gt;&amp; mp)
{
	for (typename map&lt;K, V&gt;::const_iterator it = mp.begin(); it != mp.end(); ++it)
		s &lt;&lt; (*it).first &lt;&lt; &quot; =&gt; &quot; &lt;&lt; (*it).second &lt;&lt; &quot;   &quot;;
	return s;
}
</code></pre>
<p>Inzwischen frage ich mich allerdings, ob es das nicht in irgendeiner Bibliothek gibt; in STL und Boost war ich aber nicht fündig.</p>
<p>Weiss irgendwer was dazu?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1607384</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1607384</guid><dc:creator><![CDATA[ingobulla]]></dc:creator><pubDate>Thu, 30 Oct 2008 18:18:36 GMT</pubDate></item><item><title><![CDATA[Reply to Ausgabe von STL-Containern mittels &amp;lt;&amp;lt; on Thu, 30 Oct 2008 18:35:42 GMT]]></title><description><![CDATA[<p>Ich denke nicht, dass es so etwas gibt, zumal ja die Formatierung von jedem anders gewünscht wird.</p>
<p>Du kommst wahrscheinlich nicht darum herum, den <code>operator&lt;&lt;</code> zu überladen. Aber <code>std::for_each()</code> und andere STL-Algorithmen können dir vielleicht beim Iterieren helfen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1607395</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1607395</guid><dc:creator><![CDATA[Nexus]]></dc:creator><pubDate>Thu, 30 Oct 2008 18:35:42 GMT</pubDate></item><item><title><![CDATA[Reply to Ausgabe von STL-Containern mittels &amp;lt;&amp;lt; on Thu, 30 Oct 2008 20:17:05 GMT]]></title><description><![CDATA[<p>Container können mit copy und ostream_iterator ausgegeben werden, wenn für den value_type des Containers ein Streaming-Operator existiert.<br />
Beispiel:</p>
<pre><code class="language-cpp">vector&lt; int &gt; v;
    // v füllen
    copy( v.begin(), v.end(), ostream_iterator&lt; int &gt;( cout, &quot; &quot; ) );
</code></pre>
<p>Bem.: ostream_iterator erfordert #include &lt;iterator&gt;</p>
<p>Gruß<br />
Werner</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1607465</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1607465</guid><dc:creator><![CDATA[Werner Salomon]]></dc:creator><pubDate>Thu, 30 Oct 2008 20:17:05 GMT</pubDate></item><item><title><![CDATA[Reply to Ausgabe von STL-Containern mittels &amp;lt;&amp;lt; on Thu, 30 Oct 2008 22:30:44 GMT]]></title><description><![CDATA[<p>schau mal unter <a href="http://www.boost.org/doc/libs/1_36_0/libs/serialization/doc/index.html" rel="nofollow">http://www.boost.org/doc/libs/1_36_0/libs/serialization/doc/index.html</a> ob das was für die ichst, die habens zumindest für standardcontainer schon fertig...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1607563</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1607563</guid><dc:creator><![CDATA[pumuckl]]></dc:creator><pubDate>Thu, 30 Oct 2008 22:30:44 GMT</pubDate></item></channel></rss>