<?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 templates und iteratoren]]></title><description><![CDATA[<p>Hallo!</p>
<p>Hoffe das ist keine dumme Frage...</p>
<p>Wollte mir ne Warpper um std::map schreiben...</p>
<pre><code class="language-cpp">template &lt; class K, class T&gt;
class KeyMap
{
    //[...]
    private:
        std::map&lt; K, T &gt; mMap;
        std::map&lt; K, T &gt;::iterator mIter; // &lt;-- geht nicht, wieso???
};
</code></pre>
<p>Wie kriege ich jetzt den Iterator???<br />
hatte das gleiche problem schonmal als ich eine erweiterte Klasse um std:vector geschrieben hab, aber dort habe ich einfach vermieden einen iterator zu nehmen.<br />
Denn auch in den Methoden kann ich keinen definieren.<br />
Wieso nicht bzw. was ist daran falsch, wie mache ich es richtig??</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/119311/std-templates-und-iteratoren</link><generator>RSS for Node</generator><lastBuildDate>Fri, 21 Aug 2026 22:22:43 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/119311.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 30 Aug 2005 18:44:37 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to std templates und iteratoren on Tue, 30 Aug 2005 18:44:37 GMT]]></title><description><![CDATA[<p>Hallo!</p>
<p>Hoffe das ist keine dumme Frage...</p>
<p>Wollte mir ne Warpper um std::map schreiben...</p>
<pre><code class="language-cpp">template &lt; class K, class T&gt;
class KeyMap
{
    //[...]
    private:
        std::map&lt; K, T &gt; mMap;
        std::map&lt; K, T &gt;::iterator mIter; // &lt;-- geht nicht, wieso???
};
</code></pre>
<p>Wie kriege ich jetzt den Iterator???<br />
hatte das gleiche problem schonmal als ich eine erweiterte Klasse um std:vector geschrieben hab, aber dort habe ich einfach vermieden einen iterator zu nehmen.<br />
Denn auch in den Methoden kann ich keinen definieren.<br />
Wieso nicht bzw. was ist daran falsch, wie mache ich es richtig??</p>
]]></description><link>https://www.c-plusplus.net/forum/post/861618</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/861618</guid><dc:creator><![CDATA[Ridley]]></dc:creator><pubDate>Tue, 30 Aug 2005 18:44:37 GMT</pubDate></item><item><title><![CDATA[Reply to std templates und iteratoren on Tue, 30 Aug 2005 18:46:32 GMT]]></title><description><![CDATA[<p>typename vergessen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/861620</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/861620</guid><dc:creator><![CDATA[typename]]></dc:creator><pubDate>Tue, 30 Aug 2005 18:46:32 GMT</pubDate></item><item><title><![CDATA[Reply to std templates und iteratoren on Tue, 30 Aug 2005 20:07:28 GMT]]></title><description><![CDATA[<p>wo, wie, was?? kann jemand ein beispiel geben, habe erst seit kurzem zum ersten mal selbst templates erstellt... wo müsste ich &quot;typename&quot; verwenden?</p>
<p>btw: wann benutzt man typename und wann class??<br />
sind template &lt; typename T &gt; und template &lt; class T &gt; nicht identisch? Wo liegt der Unterschied?</p>
<p>...man sieht, ich brauche input... *g*</p>
]]></description><link>https://www.c-plusplus.net/forum/post/861669</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/861669</guid><dc:creator><![CDATA[Ridley]]></dc:creator><pubDate>Tue, 30 Aug 2005 20:07:28 GMT</pubDate></item><item><title><![CDATA[Reply to std templates und iteratoren on Tue, 30 Aug 2005 20:08:55 GMT]]></title><description><![CDATA[<p>ich meinte:</p>
<p>typename std::map&lt; K, T &gt;::iterator mIter;</p>
]]></description><link>https://www.c-plusplus.net/forum/post/861670</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/861670</guid><dc:creator><![CDATA[output]]></dc:creator><pubDate>Tue, 30 Aug 2005 20:08:55 GMT</pubDate></item><item><title><![CDATA[Reply to std templates und iteratoren on Tue, 30 Aug 2005 20:16:08 GMT]]></title><description><![CDATA[<p>ah, ok, so gehts, thx:</p>
<pre><code class="language-cpp">template &lt; class K, class T&gt;
class KeyMap
{
    //[...]
    private:
        std::map&lt; K, T &gt; mMap;
        typename std::map&lt; K, T &gt;::iterator mIter;
};
</code></pre>
<p>hat vll. jemand link wo das schlüsselwort &quot;typename&quot; näher erklärt wird?<br />
meiner meinung nach müsste auch ein std:map&lt;K, T&gt; den richtigen iterator liefern. Wozu den Umstand mit einem zusätzlichen Schlüsselwort??</p>
]]></description><link>https://www.c-plusplus.net/forum/post/861676</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/861676</guid><dc:creator><![CDATA[Ridley]]></dc:creator><pubDate>Tue, 30 Aug 2005 20:16:08 GMT</pubDate></item><item><title><![CDATA[Reply to std templates und iteratoren on Tue, 30 Aug 2005 20:22:24 GMT]]></title><description><![CDATA[<p>Ridley schrieb:</p>
<blockquote>
<p>ah, ok, so gehts, thx:</p>
<p>hat vll. jemand link wo das schlüsselwort &quot;typename&quot; näher erklärt wird?<br />
meiner meinung nach müsste auch ein std:map&lt;K, T&gt; den richtigen iterator liefern. Wozu den Umstand mit einem zusätzlichen Schlüsselwort??</p>
</blockquote>
<p>Damit er wahrscheinlich weiss das er das Template auflösen muss,<br />
um den Typen festzustellen. Oder sowas. würd mich auch mal interessieren :p</p>
<p>btw. <a href="http://cppreference.com" rel="nofollow">cppreference.com</a> sagt:<br />
<a href="http://cppreference.com/keywords/typename.html" rel="nofollow">http://cppreference.com/keywords/typename.html</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/861677</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/861677</guid><dc:creator><![CDATA[phlox81]]></dc:creator><pubDate>Tue, 30 Aug 2005 20:22:24 GMT</pubDate></item><item><title><![CDATA[Reply to std templates und iteratoren on Tue, 30 Aug 2005 20:26:53 GMT]]></title><description><![CDATA[<p>das schlüsselwort macht deinen compiler nur darauf aufmerksam, dass &quot;iterator&quot; ein typ ist. Da der Compiler zu dem zeitpunkt noch nicht wissen kann, dass es sich um einen typ handelt musst du ihm da auf die sprünge helfen.</p>
<p>Wieso er das nicht wissen kann?</p>
<pre><code class="language-cpp">template&lt;class T&gt;
struct Foo{
    typedef T Bar;//typ
};
template&lt;&gt;
struct Foo&lt;int&gt;{
    static const int Bar=0;//zahlenkonstante
};
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/861680</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/861680</guid><dc:creator><![CDATA[otze]]></dc:creator><pubDate>Tue, 30 Aug 2005 20:26:53 GMT</pubDate></item><item><title><![CDATA[Reply to std templates und iteratoren on Tue, 30 Aug 2005 20:28:30 GMT]]></title><description><![CDATA[<p>Kurz und knapp: Ohne typename davor nimmt der Compiler an es wäre nen Objekt, da es nen Typ ist musst du ihm das mit typename sagen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/861681</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/861681</guid><dc:creator><![CDATA[User---]]></dc:creator><pubDate>Tue, 30 Aug 2005 20:28:30 GMT</pubDate></item><item><title><![CDATA[Reply to std templates und iteratoren on Wed, 31 Aug 2005 07:10:51 GMT]]></title><description><![CDATA[<p>Im Standard zu finden unter 14.6:</p>
<p><em>A name used in a template declaration or definition <strong>and that is<br />
dependent on a template-parameter</strong> is assumed not to name a type<br />
unless the applicable name lookup finds a type name or the name is<br />
qualified by the keyword <strong>typename</strong>.</em></p>
<p>Wäre das nicht was für's FAQ? (Ich hoffe, da steht's noch nicht drin :))</p>
<p>Wobei mich mal interessieren würde, wann dieser Fall eintritt:<br />
<em>unless the applicable name lookup finds a type name</em></p>
]]></description><link>https://www.c-plusplus.net/forum/post/861802</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/861802</guid><dc:creator><![CDATA[7H3 N4C3R]]></dc:creator><pubDate>Wed, 31 Aug 2005 07:10:51 GMT</pubDate></item><item><title><![CDATA[Reply to std templates und iteratoren on Wed, 31 Aug 2005 16:28:07 GMT]]></title><description><![CDATA[<p>danke für erklärungen und links... <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/862220</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/862220</guid><dc:creator><![CDATA[Ridley]]></dc:creator><pubDate>Wed, 31 Aug 2005 16:28:07 GMT</pubDate></item><item><title><![CDATA[Reply to std templates und iteratoren on Thu, 01 Sep 2005 09:42:19 GMT]]></title><description><![CDATA[<p>7H3 N4C3R schrieb:</p>
<blockquote>
<p>Wobei mich mal interessieren würde, wann dieser Fall eintritt:<br />
<em>unless the applicable name lookup finds a type name</em></p>
</blockquote>
<p>Z.B. im Fall vom Lookup von Basisklassen in einer Basisklassenliste. Hier werden non-types ignoriert, deshalb brauchst du hier auch kein typename.<br />
Beispiel:</p>
<pre><code class="language-cpp">template &lt;class T&gt;
struct Foo {
    typedef T AType;
};

template &lt;class T&gt;
struct Bar : Foo&lt;T&gt;::AType {// hier kein typename nötig
    typedef typename Foo&lt;T&gt;::AType Bae // hier aber schon

};
</code></pre>
<p>Foo&lt;T&gt;::AType ist ein abhängiger Name und muss deshalb innerhalb eines Templates mit typename qualifiziert werden. Eine Ausnahme ist die Base-Class-List, da die Lookup-Regeln hier besagen, dass non-types ignoriert werden. Hier wird also automatisch angenommen, dass Foo&lt;T&gt;::AType einen Typ bezeichnet. Sollte sich im Instanziierungskontext dann herausstellen, dass Foo&lt;T&gt;::AType kein Typ ist, dann ist dein Programm &quot;ill-formed&quot;.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/862590</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/862590</guid><dc:creator><![CDATA[HumeSikkins]]></dc:creator><pubDate>Thu, 01 Sep 2005 09:42:19 GMT</pubDate></item></channel></rss>