<?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[decltype]]></title><description><![CDATA[<p>Hi,</p>
<p>kann mir jemand die funktionalitaet decltype in folgenden code erklaeren?</p>
<pre><code>template &lt;class KEY_T, class VAL_T&gt; class LRUCache{
private:
        list&lt;pair&lt;KEY_T,VAL_T&gt;&gt; item_list;
        unordered_map&lt;KEY_T, decltype(item_list.begin())&gt; item_map;
</code></pre>
<p>koennte ich auch einen iterator speichern?</p>
<pre><code>list&lt;pair&lt;KEY_T,VAL_T&gt;&gt;::iterator it;
unordered_map&lt;KEY_T, it&gt; item_map;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/322250/decltype</link><generator>RSS for Node</generator><lastBuildDate>Sat, 18 Jul 2026 07:15:36 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/322250.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 12 Dec 2013 19:11:50 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to decltype on Thu, 12 Dec 2013 19:11:50 GMT]]></title><description><![CDATA[<p>Hi,</p>
<p>kann mir jemand die funktionalitaet decltype in folgenden code erklaeren?</p>
<pre><code>template &lt;class KEY_T, class VAL_T&gt; class LRUCache{
private:
        list&lt;pair&lt;KEY_T,VAL_T&gt;&gt; item_list;
        unordered_map&lt;KEY_T, decltype(item_list.begin())&gt; item_map;
</code></pre>
<p>koennte ich auch einen iterator speichern?</p>
<pre><code>list&lt;pair&lt;KEY_T,VAL_T&gt;&gt;::iterator it;
unordered_map&lt;KEY_T, it&gt; item_map;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2371429</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2371429</guid><dc:creator><![CDATA[cppcoder1]]></dc:creator><pubDate>Thu, 12 Dec 2013 19:11:50 GMT</pubDate></item><item><title><![CDATA[Reply to decltype on Thu, 12 Dec 2013 19:31:40 GMT]]></title><description><![CDATA[<p>Jo,</p>
<pre><code class="language-cpp">typedef typename list&lt;pair&lt;KEY_T,VAL_T&gt;&gt;::iterator it; // man beachte das typename
unordered_map&lt;KEY_T, it&gt; item_map;
</code></pre>
<p>macht das gleiche wie</p>
<pre><code class="language-cpp">unordered_map&lt;KEY_T, decltype(item_list.begin())&gt; item_map;
</code></pre>
<p>Aber eines ist kürzer, lesbarer und muss nicht angepasst werden, wenn man den Typ von item_list auf einen vector/deque ändert, weil man feststellt, dass das doch schneller ist.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2371438</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2371438</guid><dc:creator><![CDATA[deckeltyp]]></dc:creator><pubDate>Thu, 12 Dec 2013 19:31:40 GMT</pubDate></item><item><title><![CDATA[Reply to decltype on Thu, 12 Dec 2013 20:16:05 GMT]]></title><description><![CDATA[<p>vector/deque sollte man hier keine verwenden, da die iteratoren unglueltig werden wenn ich neue element in den vector order deque hinzufuege oder loesche?</p>
<p>warum klappt die def. des iterators nicht ohne dem typename, wuerde das mit c++98 compilieren?</p>
<pre><code>typedef list&lt;pair&lt;KEY_T,VAL_T&gt;&gt;::iterator it;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2371463</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2371463</guid><dc:creator><![CDATA[cppcoder1]]></dc:creator><pubDate>Thu, 12 Dec 2013 20:16:05 GMT</pubDate></item><item><title><![CDATA[Reply to decltype on Thu, 12 Dec 2013 20:25:44 GMT]]></title><description><![CDATA[<ol>
<li>
<p>Nein, deque invalidiert Iteratoren nur, wenn in der Mitte (d.h. nicht am Rand) eingefügt wird.</p>
</li>
<li>
<p>Ne, das typename ist Pflicht. In C++98, wie in C++11. Kann sein, dass der MSVC das durchgehen lässt, aber das dürfte er eigentlich nicht. Denn &quot;list&lt;pair&lt;KEY_T,VAL_T&gt;&gt;::iterator&quot; könnte ja rein theoretisch auch eine Konstante sein (wie max_size oder so). <a href="http://stackoverflow.com/questions/610245/where-and-why-do-i-have-to-put-the-template-and-typename-keywords" rel="nofollow">http://stackoverflow.com/questions/610245/where-and-why-do-i-have-to-put-the-template-and-typename-keywords</a></p>
</li>
</ol>
]]></description><link>https://www.c-plusplus.net/forum/post/2371469</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2371469</guid><dc:creator><![CDATA[deckeltyp]]></dc:creator><pubDate>Thu, 12 Dec 2013 20:25:44 GMT</pubDate></item><item><title><![CDATA[Reply to decltype on Thu, 12 Dec 2013 20:32:33 GMT]]></title><description><![CDATA[<p>typename braucht man nur bei verschachtelten abhängigen typen:</p>
<pre><code>struct Foo
{
	typedef int Type;
};
template&lt;typename T&gt;
void f1()
{
	T Instance; // Kein typename weil T nicht verschachtelt ist
}
void f2()
{
	Foo::Type Instance; // Kein typename weil Foo nicht abhängig ist
}
template&lt;typename T&gt;
void f3()
{
	typename T::Type Instance; // typename weil T abhängig ist und weil Type verschachtelt ist
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2371471</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2371471</guid><dc:creator><![CDATA[asdfasdf]]></dc:creator><pubDate>Thu, 12 Dec 2013 20:32:33 GMT</pubDate></item><item><title><![CDATA[Reply to decltype on Fri, 13 Dec 2013 06:26:01 GMT]]></title><description><![CDATA[<p>decltype gekommt den type zur compiletime?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2371518</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2371518</guid><dc:creator><![CDATA[cppcoder1]]></dc:creator><pubDate>Fri, 13 Dec 2013 06:26:01 GMT</pubDate></item><item><title><![CDATA[Reply to decltype on Fri, 13 Dec 2013 07:15:56 GMT]]></title><description><![CDATA[<p>cppcoder1 schrieb:</p>
<blockquote>
<p>decltype gekommt den type zur compiletime?</p>
</blockquote>
<p>ja. anders wäre das gar nicht möglich mit einem starken typensystem wie es c++ hat.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2371527</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2371527</guid><dc:creator><![CDATA[asdfasdf]]></dc:creator><pubDate>Fri, 13 Dec 2013 07:15:56 GMT</pubDate></item><item><title><![CDATA[Reply to decltype on Fri, 13 Dec 2013 07:52:48 GMT]]></title><description><![CDATA[<p>asdfasdf schrieb:</p>
<blockquote>
<p>cppcoder1 schrieb:</p>
<blockquote>
<p>decltype gekommt den type zur compiletime?</p>
</blockquote>
<p>ja. anders wäre das gar nicht möglich mit einem starken typensystem wie es c++ hat.</p>
</blockquote>
<p>Es gibt da auch noch so Späßchen wie dynamic_cast und typeid, auch wenn sie kaum benutzt werden.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2371535</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2371535</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Fri, 13 Dec 2013 07:52:48 GMT</pubDate></item><item><title><![CDATA[Reply to decltype on Fri, 13 Dec 2013 08:20:12 GMT]]></title><description><![CDATA[<p>Und noch allgemeiner:</p>
<pre><code>decltype(std::begin(item_list))
</code></pre>
<blockquote>
<p>Es gibt da auch noch so Späßchen wie dynamic_cast und typeid, auch wenn sie kaum benutzt werden.</p>
</blockquote>
<p>Es geht hier um Template-Argumente.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2371543</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2371543</guid><dc:creator><![CDATA[Columbo]]></dc:creator><pubDate>Fri, 13 Dec 2013 08:20:12 GMT</pubDate></item></channel></rss>