<?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[std::vector an anderne std::vector anhängen.]]></title><description><![CDATA[<p>Hallo zusammen,</p>
<p>besteht eine &quot;einfache&quot; Möglichkeit die Elemente eines std::vectors direkt an einen anderen std::vector anzuhängen?</p>
<p>Also:</p>
<pre><code class="language-cpp">std::vector&lt;int&gt; Vec1, Vec2;

Vec1.insert(Vec1.begin(), 1);
Vec1.insert(Vec1.begin(), 2);
Vec1.insert(Vec1.begin(), 3);

Vec2.insert(Vec1.begin(), 2);

// Jetzt der Befehl das Vec1 an Vec2 angehängt wird
</code></pre>
<p>So dass die Ausgabe ist:<br />
Vec2[0] = 2<br />
Vec2[1] = 1<br />
Vec2[2] = 2<br />
Vec2[3] = 3</p>
<p>Oder gibt es dafür keine Möglichkeit und ich muss es mit ner Schleife selber schreiben :).</p>
<p>Danke</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/177828/std-vector-an-anderne-std-vector-anhängen</link><generator>RSS for Node</generator><lastBuildDate>Sun, 20 Sep 2026 03:41:28 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/177828.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 04 Apr 2007 13:31:29 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to std::vector an anderne std::vector anhängen. on Wed, 04 Apr 2007 13:31:29 GMT]]></title><description><![CDATA[<p>Hallo zusammen,</p>
<p>besteht eine &quot;einfache&quot; Möglichkeit die Elemente eines std::vectors direkt an einen anderen std::vector anzuhängen?</p>
<p>Also:</p>
<pre><code class="language-cpp">std::vector&lt;int&gt; Vec1, Vec2;

Vec1.insert(Vec1.begin(), 1);
Vec1.insert(Vec1.begin(), 2);
Vec1.insert(Vec1.begin(), 3);

Vec2.insert(Vec1.begin(), 2);

// Jetzt der Befehl das Vec1 an Vec2 angehängt wird
</code></pre>
<p>So dass die Ausgabe ist:<br />
Vec2[0] = 2<br />
Vec2[1] = 1<br />
Vec2[2] = 2<br />
Vec2[3] = 3</p>
<p>Oder gibt es dafür keine Möglichkeit und ich muss es mit ner Schleife selber schreiben :).</p>
<p>Danke</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1259286</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1259286</guid><dc:creator><![CDATA[Orion_20]]></dc:creator><pubDate>Wed, 04 Apr 2007 13:31:29 GMT</pubDate></item><item><title><![CDATA[Reply to std::vector an anderne std::vector anhängen. on Wed, 04 Apr 2007 13:32:16 GMT]]></title><description><![CDATA[<p>Es muss natürlich</p>
<p>Vec2.insert(Vec2.begin(), 2); anstelle von Vec2.insert(Vec1.begin(), 2); heißen <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1259287</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1259287</guid><dc:creator><![CDATA[Orion_20]]></dc:creator><pubDate>Wed, 04 Apr 2007 13:32:16 GMT</pubDate></item><item><title><![CDATA[Reply to std::vector an anderne std::vector anhängen. on Wed, 04 Apr 2007 13:35:04 GMT]]></title><description><![CDATA[<p>Klar:<br />
<a href="http://www.cppreference.com/cppalgorithm/copy.html" rel="nofollow">http://www.cppreference.com/cppalgorithm/copy.html</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1259292</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1259292</guid><dc:creator><![CDATA[Artchi]]></dc:creator><pubDate>Wed, 04 Apr 2007 13:35:04 GMT</pubDate></item><item><title><![CDATA[Reply to std::vector an anderne std::vector anhängen. on Wed, 04 Apr 2007 13:35:34 GMT]]></title><description><![CDATA[<p>Du kannst anstelle eines einzelnen Wertes auch einen Iterator-Bereich als Quelle für insert() angeben - hier also <code>Vec2.insert(Vec2.end()/*Position*/,Vec1.begin(),Vec1.end());</code> (oder du verwendest copy() mit einem back_inserter)</p>
<p>PS: Dir ist hoffentlich klar, daß die Werte jetzt rückwärts in Vec1 stehen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1259293</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1259293</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Wed, 04 Apr 2007 13:35:34 GMT</pubDate></item><item><title><![CDATA[Reply to std::vector an anderne std::vector anhängen. on Wed, 04 Apr 2007 13:37:37 GMT]]></title><description><![CDATA[<blockquote>
<p>PS: Dir ist hoffentlich klar, daß die Werte jetzt rückwärts in Vec1 stehen.</p>
</blockquote>
<p>Jo, ist klar :)... (EDIT: begin = end ;))</p>
<p>Vielen dank!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1259294</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1259294</guid><dc:creator><![CDATA[Orion_20]]></dc:creator><pubDate>Wed, 04 Apr 2007 13:37:37 GMT</pubDate></item></channel></rss>