<?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::map::iterator::second - Zuweisung sicher?]]></title><description><![CDATA[<p>Hallo.<br />
Ist es sicher und valid folgendes zu machen?</p>
<pre><code class="language-cpp">map&lt;int, unsigned long*&gt;::iterator it = this-&gt;m_Offsets.find(myInt);

if (it == this-&gt;m_Offsets.end())
{
    this-&gt;m_Offsets[myInt] = myULong;
}
else
{
    delete[] it-&gt;second;
    it-&gt;second = myULong;
}
</code></pre>
<p>Gruß &amp; Danke!</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/268235/std-map-iterator-second-zuweisung-sicher</link><generator>RSS for Node</generator><lastBuildDate>Tue, 01 Sep 2026 22:06:07 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/268235.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 06 Jun 2010 12:17:17 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to std::map::iterator::second - Zuweisung sicher? on Sun, 06 Jun 2010 12:17:17 GMT]]></title><description><![CDATA[<p>Hallo.<br />
Ist es sicher und valid folgendes zu machen?</p>
<pre><code class="language-cpp">map&lt;int, unsigned long*&gt;::iterator it = this-&gt;m_Offsets.find(myInt);

if (it == this-&gt;m_Offsets.end())
{
    this-&gt;m_Offsets[myInt] = myULong;
}
else
{
    delete[] it-&gt;second;
    it-&gt;second = myULong;
}
</code></pre>
<p>Gruß &amp; Danke!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1907721</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1907721</guid><dc:creator><![CDATA[theliquidwave]]></dc:creator><pubDate>Sun, 06 Jun 2010 12:17:17 GMT</pubDate></item><item><title><![CDATA[Reply to std::map::iterator::second - Zuweisung sicher? on Sun, 06 Jun 2010 12:21:32 GMT]]></title><description><![CDATA[<p>ich würde mal sagen, dass das delete[] falsch ist und du delete verwenden solltest - dazu müsste man aber erst mal sehen, wie du das objekt erzeugt hast.</p>
<p>myULong klingt so und so nicht nach nem array - wieso dann also der umweg über pointer?</p>
<p>bb</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1907724</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1907724</guid><dc:creator><![CDATA[unskilled]]></dc:creator><pubDate>Sun, 06 Jun 2010 12:21:32 GMT</pubDate></item><item><title><![CDATA[Reply to std::map::iterator::second - Zuweisung sicher? on Sun, 06 Jun 2010 12:28:19 GMT]]></title><description><![CDATA[<p>Ja. Da allerdings der Elementzugriff selbst prüft, ob ein bestimmter Schlüssel schon verhanden ist, scheint mir das doppelte Arbeit zu sein.</p>
<pre><code class="language-cpp">unsigned long*&amp; v = m_Offsets[myInt];
delete [] v;
v = myULong;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1907727</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1907727</guid><dc:creator><![CDATA[camper]]></dc:creator><pubDate>Sun, 06 Jun 2010 12:28:19 GMT</pubDate></item><item><title><![CDATA[Reply to std::map::iterator::second - Zuweisung sicher? on Sun, 06 Jun 2010 12:38:17 GMT]]></title><description><![CDATA[<p>Danke!</p>
<p>Gruß</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1907729</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1907729</guid><dc:creator><![CDATA[theliquidwave]]></dc:creator><pubDate>Sun, 06 Jun 2010 12:38:17 GMT</pubDate></item></channel></rss>