<?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[Problem mit std::map]]></title><description><![CDATA[<p>Hi.<br />
Ich hab folgendes:</p>
<pre><code class="language-cpp">typedef std::map&lt;std::string, std::string&gt; TConfigPair;
typedef std::map&lt;std::string, TConfigPair*&gt; TConfigList;

TConfigList* findGroupByName(std::string gruppenname);

void addConfigValue(std::string gruppe, std::string name, std::string value)
{
   TConfigList* gruppe = findGroupByName(gruppe);
   gruppe[name] = value;
}
</code></pre>
<p>Fehlermeldung:</p>
<blockquote>
<p>error C2677: binary '[' : no global operator found which takes type 'std::string' (or there is no acceptable conversion)</p>
</blockquote>
<p>Warum geht das nicht?<br />
lg</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/266378/problem-mit-std-map</link><generator>RSS for Node</generator><lastBuildDate>Thu, 03 Sep 2026 07:14:13 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/266378.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 07 May 2010 21:15:49 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Problem mit std::map on Fri, 07 May 2010 21:15:49 GMT]]></title><description><![CDATA[<p>Hi.<br />
Ich hab folgendes:</p>
<pre><code class="language-cpp">typedef std::map&lt;std::string, std::string&gt; TConfigPair;
typedef std::map&lt;std::string, TConfigPair*&gt; TConfigList;

TConfigList* findGroupByName(std::string gruppenname);

void addConfigValue(std::string gruppe, std::string name, std::string value)
{
   TConfigList* gruppe = findGroupByName(gruppe);
   gruppe[name] = value;
}
</code></pre>
<p>Fehlermeldung:</p>
<blockquote>
<p>error C2677: binary '[' : no global operator found which takes type 'std::string' (or there is no acceptable conversion)</p>
</blockquote>
<p>Warum geht das nicht?<br />
lg</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1894023</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1894023</guid><dc:creator><![CDATA[f&#x27;ckw]]></dc:creator><pubDate>Fri, 07 May 2010 21:15:49 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit std::map on Fri, 07 May 2010 21:17:18 GMT]]></title><description><![CDATA[<p>Grrr, verschrieben. In der Funktion solls natürlich TConfigPair* heissen und nicht TConfigList.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1894024</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1894024</guid><dc:creator><![CDATA[f&#x27;ckw]]></dc:creator><pubDate>Fri, 07 May 2010 21:17:18 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit std::map on Fri, 07 May 2010 21:17:51 GMT]]></title><description><![CDATA[<p>gruppe ist ein Zeiger, diesen musst du erst dereferenzieren.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1894026</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1894026</guid><dc:creator><![CDATA[Janjan]]></dc:creator><pubDate>Fri, 07 May 2010 21:17:51 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit std::map on Fri, 07 May 2010 21:21:24 GMT]]></title><description><![CDATA[<p>Ist dir schon mal aufgefallen, dass gruppe zu einem ein <code>std::string</code> und zum anderen ein <code>TConfigList</code> ist?</p>
<p>Gruß</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1894029</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1894029</guid><dc:creator><![CDATA[theliquidwave]]></dc:creator><pubDate>Fri, 07 May 2010 21:21:24 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit std::map on Fri, 07 May 2010 21:27:52 GMT]]></title><description><![CDATA[<p>Janjan schrieb:</p>
<blockquote>
<p>gruppe ist ein Zeiger, diesen musst du erst dereferenzieren.</p>
</blockquote>
<p>Wie macht man das richtig?<br />
Weil</p>
<pre><code class="language-cpp">*(gruppe)[name] = value;
</code></pre>
<p>funktioniert nicht.</p>
<pre><code class="language-cpp">TConfigPair&amp; ref = *gruppe;
ref[name] = value;
</code></pre>
<p>Das geht. Aber kann man das auch anders schreiben?<br />
lg</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1894034</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1894034</guid><dc:creator><![CDATA[f&#x27;ckw]]></dc:creator><pubDate>Fri, 07 May 2010 21:27:52 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit std::map on Fri, 07 May 2010 21:29:42 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">(*gruppe)[name] = value;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1894037</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1894037</guid><dc:creator><![CDATA[theliquidwave]]></dc:creator><pubDate>Fri, 07 May 2010 21:29:42 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit std::map on Fri, 07 May 2010 21:30:53 GMT]]></title><description><![CDATA[<p>f'ckw schrieb:</p>
<blockquote>
<p>Janjan schrieb:</p>
<blockquote>
<p>gruppe ist ein Zeiger, diesen musst du erst dereferenzieren.</p>
</blockquote>
<p>Wie macht man das richtig?<br />
Weil</p>
<pre><code class="language-cpp">*(gruppe)[name] = value;
</code></pre>
</blockquote>
<p>Erst dereferenzieren, dann operator[] nutzen. Benutze runde Klammern, um die Reihenfolge zu ändern ([] hat höhere Priorität als *). Du machst es falsch, deine Klammern ändern rein gar nichts an der Reihenfolge. Bitte mitdenken.</p>
<p>theliquidwave schrieb:</p>
<blockquote>
<pre><code class="language-cpp">(*gruppe)[name] = value;
</code></pre>
</blockquote>
<p>Sehr schön, am besten kaust du ihm auch gleich sein Essen vor.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1894038</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1894038</guid><dc:creator><![CDATA[Janjan]]></dc:creator><pubDate>Fri, 07 May 2010 21:30:53 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit std::map on Fri, 07 May 2010 21:31:05 GMT]]></title><description><![CDATA[<p>theliquidwave schrieb:</p>
<blockquote>
<pre><code class="language-cpp">(*gruppe)[name] = value;
</code></pre>
</blockquote>
<p>Vielen Dank <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="🙂"
    /><br />
lg</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1894039</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1894039</guid><dc:creator><![CDATA[f&#x27;ckw]]></dc:creator><pubDate>Fri, 07 May 2010 21:31:05 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit std::map on Fri, 07 May 2010 21:33:57 GMT]]></title><description><![CDATA[<p>Janjan schrieb:</p>
<blockquote>
<p>Sehr schön, am besten kaust du ihm auch gleich sein Essen vor.</p>
</blockquote>
<p>Aha. Normalerweise bin ich auch gegen solche Posts. Aber der Unterschied zwischen seiner und meiner Lösung ist offensichtlich. Warum das so funktioniert ist doch selbsterklärend...</p>
<p>Gruß</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1894041</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1894041</guid><dc:creator><![CDATA[theliquidwave]]></dc:creator><pubDate>Fri, 07 May 2010 21:33:57 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit std::map on Fri, 07 May 2010 21:49:57 GMT]]></title><description><![CDATA[<p>theliquidwave schrieb:</p>
<blockquote>
<p>Janjan schrieb:</p>
<blockquote>
<p>Sehr schön, am besten kaust du ihm auch gleich sein Essen vor.</p>
</blockquote>
<p>Aha. Normalerweise bin ich auch gegen solche Posts. Aber der Unterschied zwischen seiner und meiner Lösung ist offensichtlich. Warum das so funktioniert ist doch selbsterklärend...</p>
</blockquote>
<p>Wenn man es weiss, ja. Allerdings wenn es so offensichtlich ist, wieso hat er es dann nicht selbst schon gemacht? Womöglich weil es für ihn nicht so offensichtlich war?</p>
<p>Es ist immer gefährlich jemandem sowas einfach vorzulegen. Viele nicken mit dem Kopf, man hat das Gefühl, dass sie es verstanden haben, wenn man dann allerdings nachfragt, merkt man, dass überhaupt nichts klar wurde. Und die Gefahr ist leider gross, dass viele einfach nur Copy&amp;Paste machen, wenn sie eine Lösung geliefert bekommen, statt sich nochmals Gedanken darüber zu machen, wieso dies nun die Lösung ist. Traurig, aber leider sieht man es immer und immer wieder, auch bei solchen offensichtlichen kleinen Dingen.</p>
<p>Grüssli</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1894044</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1894044</guid><dc:creator><![CDATA[Dravere]]></dc:creator><pubDate>Fri, 07 May 2010 21:49:57 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit std::map on Fri, 07 May 2010 22:40:59 GMT]]></title><description><![CDATA[<p>Muss euch nochmal belästigen.</p>
<p>So schauts momentan aus:</p>
<pre><code class="language-cpp">typedef std::map&lt;std::string, std::string&gt; TConfigPair;
typedef std::map&lt;std::string, TConfigPair*&gt; TConfigList;

TConfigList* findGroupByName(std::string gruppenname);

void addConfigValue(std::string grpName, std::string name, std::string value)
{
   TConfigPair* gruppe = findGroupByName(grpName);
   gruppe-&gt;insert(std::make_pair(name, value);
}
</code></pre>
<p>So hab ich das. Das Testprogramm stürzt aber beim insert mit einer Excpetion ab</p>
<blockquote>
<p>Unhandled exception at 0x68c15fb1: 0xC0000005: Access violation reading location 0x00000014.</p>
</blockquote>
<p>Ich verstehe ehrlich gesagt nicht warum.<br />
Bitte um eure Hilfe nochmals.<br />
Bin noch nicht so erfahren mit maps.<br />
lg</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1894079</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1894079</guid><dc:creator><![CDATA[f&#x27;ckw]]></dc:creator><pubDate>Fri, 07 May 2010 22:40:59 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit std::map on Fri, 07 May 2010 22:43:59 GMT]]></title><description><![CDATA[<p>Was gibt denn <code>findGroupByName</code> zurück? Womöglich einen Nullpointer? Debugger anwerfen und schauen gehen <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
<p>Grüssli</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1894084</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1894084</guid><dc:creator><![CDATA[Dravere]]></dc:creator><pubDate>Fri, 07 May 2010 22:43:59 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit std::map on Fri, 07 May 2010 23:03:44 GMT]]></title><description><![CDATA[<p>Sorry, habe 3 überladene Funktionen die diesen Code beinhalten und in einer stand nicht gruppe = findGroup.. sondern nur das findGroup...<br />
Typischer Fall von spät programmieren :D.<br />
Danke *g*<br />
lg</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1894096</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1894096</guid><dc:creator><![CDATA[f&#x27;ckw]]></dc:creator><pubDate>Fri, 07 May 2010 23:03:44 GMT</pubDate></item></channel></rss>