<?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[Ungewollt read-only structure erschaffen]]></title><description><![CDATA[<p>Hallo,</p>
<p>in meinem Programm kommen folgenden Zeilen Code vor:</p>
<pre><code class="language-cpp">set&lt; pair&lt;set&lt;int&gt;, node*&gt; &gt;::iterator it = part_nodes[0]-&gt;subs.grouped_subs.begin();
it-&gt;second = NULL;
pair&lt;set&lt;int&gt;, node*&gt;* p = &amp;(*it);
</code></pre>
<p>Die erste Zeile ist offensichtlich nur mit längeren Erklärungen verständlich. Von daher hoffe ich, dass hier erst einmal genügt festzustellen, dass<br />
- der Compiler keine Fehlermeldung für sie ausgibt, die Initialisierung von &quot;it&quot; also (für den Compiler) durchführbar ist,<br />
- &quot;node&quot; irgendeine Klasse ist</p>
<p>Für die zweite Zeile erhalte ich allerdings</p>
<blockquote>
<p>assignment of data-member ‘std::pair&lt;std::set&lt;int, std::less&lt;int&gt;, std::allocator&lt;int&gt; &gt;, node*&gt;::second’ in read-only structure</p>
</blockquote>
<p>und für die dritte</p>
<blockquote>
<p>invalid conversion from ‘const std::pair&lt;std::set&lt;int, std::less&lt;int&gt;, std::allocator&lt;int&gt; &gt;, node*&gt;<em>’ to ‘std::pair&lt;std::set&lt;int, std::less&lt;int&gt;, std::allocator&lt;int&gt; &gt;, node</em>&gt;*’</p>
</blockquote>
<p>Weiß jemand, was hier passiert? &quot;it&quot; ist doch ein Iterator auf ein</p>
<pre><code class="language-cpp">set&lt; pair&lt;set&lt;int&gt;, node*&gt; &gt;
</code></pre>
<p>Wo ist hier irgendetwas read-only / konstant?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/206806/ungewollt-read-only-structure-erschaffen</link><generator>RSS for Node</generator><lastBuildDate>Sat, 10 Oct 2026 15:53:22 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/206806.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 29 Feb 2008 11:13:09 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Ungewollt read-only structure erschaffen on Fri, 29 Feb 2008 11:13:09 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>in meinem Programm kommen folgenden Zeilen Code vor:</p>
<pre><code class="language-cpp">set&lt; pair&lt;set&lt;int&gt;, node*&gt; &gt;::iterator it = part_nodes[0]-&gt;subs.grouped_subs.begin();
it-&gt;second = NULL;
pair&lt;set&lt;int&gt;, node*&gt;* p = &amp;(*it);
</code></pre>
<p>Die erste Zeile ist offensichtlich nur mit längeren Erklärungen verständlich. Von daher hoffe ich, dass hier erst einmal genügt festzustellen, dass<br />
- der Compiler keine Fehlermeldung für sie ausgibt, die Initialisierung von &quot;it&quot; also (für den Compiler) durchführbar ist,<br />
- &quot;node&quot; irgendeine Klasse ist</p>
<p>Für die zweite Zeile erhalte ich allerdings</p>
<blockquote>
<p>assignment of data-member ‘std::pair&lt;std::set&lt;int, std::less&lt;int&gt;, std::allocator&lt;int&gt; &gt;, node*&gt;::second’ in read-only structure</p>
</blockquote>
<p>und für die dritte</p>
<blockquote>
<p>invalid conversion from ‘const std::pair&lt;std::set&lt;int, std::less&lt;int&gt;, std::allocator&lt;int&gt; &gt;, node*&gt;<em>’ to ‘std::pair&lt;std::set&lt;int, std::less&lt;int&gt;, std::allocator&lt;int&gt; &gt;, node</em>&gt;*’</p>
</blockquote>
<p>Weiß jemand, was hier passiert? &quot;it&quot; ist doch ein Iterator auf ein</p>
<pre><code class="language-cpp">set&lt; pair&lt;set&lt;int&gt;, node*&gt; &gt;
</code></pre>
<p>Wo ist hier irgendetwas read-only / konstant?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1465299</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1465299</guid><dc:creator><![CDATA[ingobulla]]></dc:creator><pubDate>Fri, 29 Feb 2008 11:13:09 GMT</pubDate></item><item><title><![CDATA[Reply to Ungewollt read-only structure erschaffen on Fri, 29 Feb 2008 11:22:32 GMT]]></title><description><![CDATA[<p>Der Schlüssel ist konstant, und zwar generell bei assoziativen Containern, da sich beim Ändern des Schlüssels die Ordnung innerhalb der Datenstruktur ändern könnte. Dies könnte der Container nicht abfangen, würde dabei also inkonsistent.</p>
<p>Da bei einem Set der Schlüssel gleichzeitig der Wert ist, ist dieser auch konstant.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1465309</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1465309</guid><dc:creator><![CDATA[LordJaxom]]></dc:creator><pubDate>Fri, 29 Feb 2008 11:22:32 GMT</pubDate></item></channel></rss>