<?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[typename in template funktion]]></title><description><![CDATA[<p>Hi ich hab ne Frage zu typename. Folgendes:<br />
So kompilierts:</p>
<pre><code class="language-cpp">template &lt;typename T, typename pred&gt;
void vector_print_if(vector&lt;T&gt;&amp; vec,pred predicate){
  for (typename vector&lt;T&gt;::iterator i=vec.begin();i&lt;=vec.end();++i){
    if(predicate(*i)) cout&lt;&lt;(*i)&lt;&lt;endl;
  }
}
</code></pre>
<p>So nicht:</p>
<pre><code class="language-cpp">template &lt;typename T, typename pred&gt;
void vector_print_if(vector&lt;T&gt;&amp; vec,pred predicate){
  for (vector&lt;T&gt;::iterator i=vec.begin();i&lt;=vec.end();++i){
    if(predicate(*i)) cout&lt;&lt;(*i)&lt;&lt;endl;
  }
}
</code></pre>
<p>Die Frage die sich mir hier stellt, ist, wieso muss ich hier typename einfuegen?<br />
Was macht typename da?</p>
<p>MFG<br />
chewbo</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/165014/typename-in-template-funktion</link><generator>RSS for Node</generator><lastBuildDate>Mon, 14 Sep 2026 03:19:20 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/165014.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 14 Nov 2006 19:14:00 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to typename in template funktion on Tue, 14 Nov 2006 19:14:00 GMT]]></title><description><![CDATA[<p>Hi ich hab ne Frage zu typename. Folgendes:<br />
So kompilierts:</p>
<pre><code class="language-cpp">template &lt;typename T, typename pred&gt;
void vector_print_if(vector&lt;T&gt;&amp; vec,pred predicate){
  for (typename vector&lt;T&gt;::iterator i=vec.begin();i&lt;=vec.end();++i){
    if(predicate(*i)) cout&lt;&lt;(*i)&lt;&lt;endl;
  }
}
</code></pre>
<p>So nicht:</p>
<pre><code class="language-cpp">template &lt;typename T, typename pred&gt;
void vector_print_if(vector&lt;T&gt;&amp; vec,pred predicate){
  for (vector&lt;T&gt;::iterator i=vec.begin();i&lt;=vec.end();++i){
    if(predicate(*i)) cout&lt;&lt;(*i)&lt;&lt;endl;
  }
}
</code></pre>
<p>Die Frage die sich mir hier stellt, ist, wieso muss ich hier typename einfuegen?<br />
Was macht typename da?</p>
<p>MFG<br />
chewbo</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1174702</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1174702</guid><dc:creator><![CDATA[chewbo]]></dc:creator><pubDate>Tue, 14 Nov 2006 19:14:00 GMT</pubDate></item><item><title><![CDATA[Reply to typename in template funktion on Tue, 14 Nov 2006 19:20:53 GMT]]></title><description><![CDATA[<p>Wenn du einen Typ verwendest, der von einem Templateparameter abhaengig ist brauchst du typename. Der Compiler weiss ja nicht was sich hinter vector&lt;T&gt;::iterator verbirgt, dass es ein Typ ist musst du ihm so sagen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1174713</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1174713</guid><dc:creator><![CDATA[Thomas ** 0]]></dc:creator><pubDate>Tue, 14 Nov 2006 19:20:53 GMT</pubDate></item><item><title><![CDATA[Reply to typename in template funktion on Tue, 14 Nov 2006 19:22:40 GMT]]></title><description><![CDATA[<p>chewbo schrieb:</p>
<blockquote>
<p>Die Frage die sich mir hier stellt, ist, wieso muss ich hier typename einfuegen?<br />
Was macht typename da?</p>
</blockquote>
<p>Forensuche? Google?</p>
<pre><code class="language-cpp">template &lt;&gt;
class vector&lt;int&gt;
{
public:
  int iterator;
};
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1174715</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1174715</guid><dc:creator><![CDATA[finix]]></dc:creator><pubDate>Tue, 14 Nov 2006 19:22:40 GMT</pubDate></item><item><title><![CDATA[Reply to typename in template funktion on Tue, 14 Nov 2006 19:42:24 GMT]]></title><description><![CDATA[<p>Danke fuer die schnelle Antwort Thomas. Macht sinn *lol*</p>
<p>Und wenn ich ne Antowrt auf meine Frage gefunden hätte hätt ich nicht gefragt <a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/4239">@finix</a>.</p>
<p>Geht schneller zu suchen als zu posten IMHO. Aber will hier kein Streit heraufbeschwören. Musst mir also jetzt nicht noch extra links angeben wo du ne Antwort auf meine Frage gefunden hast.</p>
<p>MFG<br />
chewbo</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1174738</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1174738</guid><dc:creator><![CDATA[chewbo]]></dc:creator><pubDate>Tue, 14 Nov 2006 19:42:24 GMT</pubDate></item><item><title><![CDATA[Reply to typename in template funktion on Wed, 15 Nov 2006 07:09:20 GMT]]></title><description><![CDATA[<p>Randfrage: Warum nimmst du nicht die vorhandenen Algorithmen der STL, statt dir etwas eigenes zu bauen? Was du da gebastelt hast, ist nichts anderes als <code>remove_copy_if(vec.begin(),vec.end(),ostream_iterator&lt;T&gt;(cout,'\n'),not1(pred));</code></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1174871</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1174871</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Wed, 15 Nov 2006 07:09:20 GMT</pubDate></item></channel></rss>