<?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::erase will nicht]]></title><description><![CDATA[<p>Hi.<br />
Auf diesen Code:</p>
<pre><code class="language-cpp">for (map&lt;string, CUserData*&gt;::iterator it = this-&gt;m_Users.begin(); it != this-&gt;m_Users.end(); )
	{
		// mach was
		it = this-&gt;m_Users.erase(it);
	}
</code></pre>
<p>Folgt dieser Fehler:</p>
<pre><code>[code]/home/axiom/test/system.cpp: In member function ‘void CSystem::FreeConfigs()’:
/home/axiom/test/system.cpp:89: error: no match for ‘operator=’ in ‘it = ((CSystem*)this)-&gt;CSystem::m_User.std::map&lt;_Key, _Tp, _Compare, _Alloc&gt;::erase [with _Key = std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, _Tp = CUserData*, _Compare = std::less&lt;std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt;, _Alloc = std::allocator&lt;std::pair&lt;const std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, CUserData*&gt; &gt;](it)’
/usr/include/c++/4.1.3/bits/stl_tree.h:152: note: candidates are: std::_Rb_tree_iterator&lt;std::pair&lt;const std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, CUserData*&gt; &gt;&amp; std::_Rb_tree_iterator&lt;std::pair&lt;const std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, CUserData*&gt; &gt;::operator=(const std::_Rb_tree_iterator&lt;std::pair&lt;const std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, CUserData*&gt; &gt;&amp;)
</code></pre>
<p>[/code]</p>
<p>Und das ganze nur unter Linux (gcc 4.1.3)<br />
Ich weiß einfach nicht wieso?!</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/277112/std-map-erase-will-nicht</link><generator>RSS for Node</generator><lastBuildDate>Wed, 26 Aug 2026 01:51:59 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/277112.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 13 Nov 2010 11:20:36 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to std::map::erase will nicht on Sat, 13 Nov 2010 11:20:36 GMT]]></title><description><![CDATA[<p>Hi.<br />
Auf diesen Code:</p>
<pre><code class="language-cpp">for (map&lt;string, CUserData*&gt;::iterator it = this-&gt;m_Users.begin(); it != this-&gt;m_Users.end(); )
	{
		// mach was
		it = this-&gt;m_Users.erase(it);
	}
</code></pre>
<p>Folgt dieser Fehler:</p>
<pre><code>[code]/home/axiom/test/system.cpp: In member function ‘void CSystem::FreeConfigs()’:
/home/axiom/test/system.cpp:89: error: no match for ‘operator=’ in ‘it = ((CSystem*)this)-&gt;CSystem::m_User.std::map&lt;_Key, _Tp, _Compare, _Alloc&gt;::erase [with _Key = std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, _Tp = CUserData*, _Compare = std::less&lt;std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt;, _Alloc = std::allocator&lt;std::pair&lt;const std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, CUserData*&gt; &gt;](it)’
/usr/include/c++/4.1.3/bits/stl_tree.h:152: note: candidates are: std::_Rb_tree_iterator&lt;std::pair&lt;const std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, CUserData*&gt; &gt;&amp; std::_Rb_tree_iterator&lt;std::pair&lt;const std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, CUserData*&gt; &gt;::operator=(const std::_Rb_tree_iterator&lt;std::pair&lt;const std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, CUserData*&gt; &gt;&amp;)
</code></pre>
<p>[/code]</p>
<p>Und das ganze nur unter Linux (gcc 4.1.3)<br />
Ich weiß einfach nicht wieso?!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1979814</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1979814</guid><dc:creator><![CDATA[Lord_Axiom]]></dc:creator><pubDate>Sat, 13 Nov 2010 11:20:36 GMT</pubDate></item><item><title><![CDATA[Reply to std::map::erase will nicht on Sat, 13 Nov 2010 11:26:23 GMT]]></title><description><![CDATA[<p>Schau mal die <a href="http://www.cplusplus.com" rel="nofollow">Dokumentation</a> an. Die von dir verwendete <code>std::map::erase()</code> -Überladung hat keinen Rückgabetyp. Da Iteratoren in assoziativen Containern gültig bleiben, kannst du Folgendes tun:</p>
<pre><code class="language-cpp">m_Users.erase(it++);
</code></pre>
<p>P.S.: Wenn du natürlich alle Elemente löschst, wäre es einfacher und schneller, am Schluss einmal <code>clear()</code> aufzurufen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1979817</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1979817</guid><dc:creator><![CDATA[Nexus]]></dc:creator><pubDate>Sat, 13 Nov 2010 11:26:23 GMT</pubDate></item><item><title><![CDATA[Reply to std::map::erase will nicht on Sat, 13 Nov 2010 11:42:12 GMT]]></title><description><![CDATA[<p>Oh, dann hat der MSVC da wohl ein extra eingebaut. Da geht das nämlich.<br />
Stimmt, aber bei std::vector gibt es ja einen Rückgabetyp. Habe nicht wirklich daran gedacht, dass sich eine std::map anders verhalten könnte. Bei std::vector würde der Iterator ja ungültig werden, wenn ich ihn lösche. In einer Map anscheinend nicht.</p>
<p>Danke <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/1979826</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1979826</guid><dc:creator><![CDATA[Lord_Axiom]]></dc:creator><pubDate>Sat, 13 Nov 2010 11:42:12 GMT</pubDate></item></channel></rss>