<?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[Fehler bei std::copy]]></title><description><![CDATA[<p>Ich habe versucht std::copy zu verwenden in folgender Weise:</p>
<pre><code class="language-cpp">void Task::writeDataRecieved(double * dataArray, size_t datasize)
{
   // save end Iterator of old saveDataArray size
   vector&lt;double&gt;::iterator copyToIterator = saveDataArray.end();
   // resize with new totalsize
   saveDataArray.resize(saveDataArray.size() + datasize);
   // copy from ... to ...
   std::copy ( dataArray, dataArray + datasize, copyToIterator);
}
</code></pre>
<p>das stürzt aber mit einer Exception in std::copy ab (Exception at 0x375b84, code: 0x80000003: breakpoint, flags=0x0)</p>
<p>sieht vielleicht jemand einen logischen Fehler?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/263288/fehler-bei-std-copy</link><generator>RSS for Node</generator><lastBuildDate>Sat, 05 Sep 2026 21:36:55 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/263288.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 18 Mar 2010 11:42:04 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Fehler bei std::copy on Thu, 18 Mar 2010 11:42:04 GMT]]></title><description><![CDATA[<p>Ich habe versucht std::copy zu verwenden in folgender Weise:</p>
<pre><code class="language-cpp">void Task::writeDataRecieved(double * dataArray, size_t datasize)
{
   // save end Iterator of old saveDataArray size
   vector&lt;double&gt;::iterator copyToIterator = saveDataArray.end();
   // resize with new totalsize
   saveDataArray.resize(saveDataArray.size() + datasize);
   // copy from ... to ...
   std::copy ( dataArray, dataArray + datasize, copyToIterator);
}
</code></pre>
<p>das stürzt aber mit einer Exception in std::copy ab (Exception at 0x375b84, code: 0x80000003: breakpoint, flags=0x0)</p>
<p>sieht vielleicht jemand einen logischen Fehler?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1870798</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1870798</guid><dc:creator><![CDATA[pospiech]]></dc:creator><pubDate>Thu, 18 Mar 2010 11:42:04 GMT</pubDate></item><item><title><![CDATA[Reply to Fehler bei std::copy on Thu, 18 Mar 2010 11:48:02 GMT]]></title><description><![CDATA[<p>Durch das Resize werden (sehr wahrscheinlich, je nach Veränderung) die Elemente an eine andere Speicherstelle kopiert. Daher sind alle bisherigen Iteratoren ungültig.</p>
<pre><code class="language-cpp">void Task::writeDataRecieved(double * dataArray, size_t datasize)
{
   // save end Iterator of old saveDataArray size
   int aOldSize = saveDataArray.size();
   // resize with new totalsize
   saveDataArray.resize(saveDataArray.size() + datasize);
   // copy from ... to ...
   std::copy ( dataArray, dataArray + datasize, saveDataArray.begin() + aOldSize);
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1870802</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1870802</guid><dc:creator><![CDATA[Fellhuhn]]></dc:creator><pubDate>Thu, 18 Mar 2010 11:48:02 GMT</pubDate></item><item><title><![CDATA[Reply to Fehler bei std::copy on Thu, 18 Mar 2010 11:50:28 GMT]]></title><description><![CDATA[<p>Ergänzung:<br />
<a href="http://magazin.c-plusplus.net/artikel/Aufbau%20der%20STL%20-%20Teil%201%3A%20Container" rel="nofollow">http://magazin.c-plusplus.net/artikel/Aufbau%20der%20STL%20-%20Teil%201%3A%20Container</a></p>
<p>Ganz unten ist eine Tabelle, welche Auskunft darüber gibt, ob die Iteratoren ungültig werden.</p>
<p>Grüssli</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1870803</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1870803</guid><dc:creator><![CDATA[Dravere]]></dc:creator><pubDate>Thu, 18 Mar 2010 11:50:28 GMT</pubDate></item><item><title><![CDATA[Reply to Fehler bei std::copy on Thu, 18 Mar 2010 14:53:29 GMT]]></title><description><![CDATA[<p>Du solltest einfach einen std::back_inserter benutzen:</p>
<pre><code>void Task::writeDataRecieved(double * dataArray, size_t datasize)
{
   // copy from ... to ...
   std::copy ( dataArray, dataArray + datasize, std::back_inserter(saveDataArray));
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1870885</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1870885</guid><dc:creator><![CDATA[manni66]]></dc:creator><pubDate>Thu, 18 Mar 2010 14:53:29 GMT</pubDate></item><item><title><![CDATA[Reply to Fehler bei std::copy on Thu, 18 Mar 2010 20:55:16 GMT]]></title><description><![CDATA[<p>Das ganze kann man auch so schreiben ohne std::copy zu verwenden.</p>
<pre><code class="language-cpp">void Task::writeDataRecieved(double * dataArray, size_t datasize)
{
    saveDataArray.insert(
        saveDataArray.end(), // Am ende einfügen
        dataArray,           // von 
        dataArray + datasize // bis
    );   
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1871058</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1871058</guid><dc:creator><![CDATA[evilissimo]]></dc:creator><pubDate>Thu, 18 Mar 2010 20:55:16 GMT</pubDate></item></channel></rss>