<?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[NULL-Ptr für container?]]></title><description><![CDATA[<p>hallo, ich stehe vor dem problem, das ich die knoten<br />
meines baumes gerne in einem vector speichern würde,</p>
<p>dazu müsste ich aber jedem knoten einen std::vector&lt;Knoten&gt;::iterator verpassen,<br />
damit er seinen &quot;Vater&quot; kennt</p>
<p>egal, was ich suche ist :<br />
eine std::vector&lt;Knoten&gt;::iterator welcher NIE passt <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 />
sowas wie einen Null-Ptr für iteratoren, gibt es sowas?<br />
denn end() ist ja meiner Meinung das ende einer Instanz eines containers,<br />
und gilt nicht für jeden container, ich hoffe ich habe mich verständlich<br />
ausgedrückt <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/topic/213295/null-ptr-für-container</link><generator>RSS for Node</generator><lastBuildDate>Wed, 14 Oct 2026 10:21:13 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/213295.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 16 May 2008 08:13:36 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to NULL-Ptr für container? on Fri, 16 May 2008 08:13:36 GMT]]></title><description><![CDATA[<p>hallo, ich stehe vor dem problem, das ich die knoten<br />
meines baumes gerne in einem vector speichern würde,</p>
<p>dazu müsste ich aber jedem knoten einen std::vector&lt;Knoten&gt;::iterator verpassen,<br />
damit er seinen &quot;Vater&quot; kennt</p>
<p>egal, was ich suche ist :<br />
eine std::vector&lt;Knoten&gt;::iterator welcher NIE passt <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 />
sowas wie einen Null-Ptr für iteratoren, gibt es sowas?<br />
denn end() ist ja meiner Meinung das ende einer Instanz eines containers,<br />
und gilt nicht für jeden container, ich hoffe ich habe mich verständlich<br />
ausgedrückt <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/1510252</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1510252</guid><dc:creator><![CDATA[KeineAhung]]></dc:creator><pubDate>Fri, 16 May 2008 08:13:36 GMT</pubDate></item><item><title><![CDATA[Reply to NULL-Ptr für container? on Fri, 16 May 2008 08:16:54 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">std:vector&lt;Knoten&gt;::iterator it= NULL;

if (it==NULL){
//Kein vater, also wurzel;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1510258</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1510258</guid><dc:creator><![CDATA[BorisDieKlinge]]></dc:creator><pubDate>Fri, 16 May 2008 08:16:54 GMT</pubDate></item><item><title><![CDATA[Reply to NULL-Ptr für container? on Fri, 16 May 2008 08:17:50 GMT]]></title><description><![CDATA[<pre><code>struct knoten {
   knoden *parent;
   any data;
   knoten() {
     parent = 0;
   }
   knoten (knoten *x) {
      parent = x;
   }
};
..
std::vector&lt;knoten*&gt; klist;

klist.push_back(new knoten(*klist.begin()));
</code></pre>
<p>iwie so..</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1510260</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1510260</guid><dc:creator><![CDATA[DocJunioR]]></dc:creator><pubDate>Fri, 16 May 2008 08:17:50 GMT</pubDate></item><item><title><![CDATA[Reply to NULL-Ptr für container? on Fri, 16 May 2008 08:22:59 GMT]]></title><description><![CDATA[<p>will bei mir mit gcc 4.1.2 nicht</p>
<pre><code>#include &lt;vector&gt;

int main()
{
std::vector&lt;double&gt;::iterator it = NULL;
if(it == NULL)
 {
 }
}
</code></pre>
<p>test.cpp: In function 'int main()':<br />
test.cpp:5: error: conversion from 'int' to non-scalar type '__gnu_cxx::__normal_iterator&lt;double*, std::vector&lt;double, std::allocator&lt;double&gt; &gt; &gt;' requested<br />
test.cpp:6: error: no match for 'operator==' in 'it == 0'</p>
<p>und die version mit den Pointern habe ich genauso schon implementiert,<br />
die will ich aber nicht mehr</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1510264</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1510264</guid><dc:creator><![CDATA[KeineAhung]]></dc:creator><pubDate>Fri, 16 May 2008 08:22:59 GMT</pubDate></item><item><title><![CDATA[Reply to NULL-Ptr für container? on Fri, 16 May 2008 08:28:30 GMT]]></title><description><![CDATA[<p>warum?<br />
btw: kannst dir auch mal die smart pointer anschauen, damit bist du vor leaks ganz gut geschützt..<br />
du könntest auch als parent einfach ein int speichern und über den []-operator drauf zugreifen. wenn dein Parent-Int = -1 ist, hats keinen..</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1510266</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1510266</guid><dc:creator><![CDATA[DocJunioR]]></dc:creator><pubDate>Fri, 16 May 2008 08:28:30 GMT</pubDate></item><item><title><![CDATA[Reply to NULL-Ptr für container? on Fri, 16 May 2008 08:28:55 GMT]]></title><description><![CDATA[<p>wenn schon, dann musst du den iterator dereferenzieren.</p>
<p>if (*it == NULL) {}</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1510267</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1510267</guid><dc:creator><![CDATA[simon.gysi]]></dc:creator><pubDate>Fri, 16 May 2008 08:28:55 GMT</pubDate></item><item><title><![CDATA[Reply to NULL-Ptr für container? on Fri, 16 May 2008 08:45:15 GMT]]></title><description><![CDATA[<p>1. Das von Boris ist Quatsch.<br />
2. Der &quot;Null-Pointer&quot; für Iteratoren ist der Ende-Iterator eines Containers. Allerdings braucht man dafür auch einen gültigen Container.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1510285</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1510285</guid><dc:creator><![CDATA[LordJaxom]]></dc:creator><pubDate>Fri, 16 May 2008 08:45:15 GMT</pubDate></item><item><title><![CDATA[Reply to NULL-Ptr für container? on Fri, 16 May 2008 08:46:25 GMT]]></title><description><![CDATA[<p>Könnte man dafür nicht einfach einen default-konstruierten Iterator nehmen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1510288</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1510288</guid><dc:creator><![CDATA[Braunstein]]></dc:creator><pubDate>Fri, 16 May 2008 08:46:25 GMT</pubDate></item><item><title><![CDATA[Reply to NULL-Ptr für container? on Fri, 16 May 2008 08:59:02 GMT]]></title><description><![CDATA[<p>Braunstein schrieb:</p>
<blockquote>
<p>Könnte man dafür nicht einfach einen default-konstruierten Iterator nehmen?</p>
</blockquote>
<p>Ich habe wegen eines anderen Problems gestern erst das Kapitel über Iteratoren im Standard gewälzt. Dabei bin ich wohl zufällig über die hier relevante Passage gestolpert:</p>
<p>24.1/5 schrieb:</p>
<blockquote>
<p>Just as a regular pointer to an array guarantees that there is a pointer value pointing past the last element of the array, so for any iterator type there is an iterator value that points past the last element of a corresponding container. These values are called past-the-end values. Values of an iterator i for which the expression <em>i is defined are called dereferenceable. The library never assumes that past-the-end values are dereferenceable. <strong>Iterators can also have singular values that are not associated with any container.</strong> [Example: After the declaration of an uninitialized pointer x (as with int</em> x;), x must always be assumed to have a singular value of a pointer. ] <strong>Results of most expressions are undefined for singular values;</strong> the only exception is an assignment of a non-singular value to an iterator that holds a singular value. In this case the singular value is overwritten the same way as any other value. Dereferenceable values are always nonsingular.</p>
</blockquote>
<p>Daraus folgere ich, dass der Ausdruck &quot;Vergleich&quot; auf einen Iterator, der Default-Konstruiert ist (sprich einen singulären Wert enthält) undefiniert ist.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1510294</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1510294</guid><dc:creator><![CDATA[LordJaxom]]></dc:creator><pubDate>Fri, 16 May 2008 08:59:02 GMT</pubDate></item><item><title><![CDATA[Reply to NULL-Ptr für container? on Fri, 16 May 2008 10:38:05 GMT]]></title><description><![CDATA[<p>simon.gysi schrieb:</p>
<blockquote>
<p>wenn schon, dann musst du den iterator dereferenzieren.</p>
<p>if (*it == NULL) {}</p>
</blockquote>
<p>ups..<br />
vergessen <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f62e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_open_mouth"
      title=":open_mouth:"
      alt="😮"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1510372</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1510372</guid><dc:creator><![CDATA[DocJunioR]]></dc:creator><pubDate>Fri, 16 May 2008 10:38:05 GMT</pubDate></item></channel></rss>