<?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[Frage zu Template am beispiel std::pair]]></title><description><![CDATA[<p>Hallo,</p>
<p>hab mal den template code (header) aus der hife kopiert:</p>
<pre><code class="language-cpp">template&lt;class Type1, class Type2&gt;
   struct pair 
   {
   typedef Type1 first_type;
   typedef Type2 second_type
   Type1 first;
   Type2 second;
   pair( );
   pair(
      const Type1&amp; __Val1, 
      const Type2&amp; __Val2
   );
   template&lt;class Other1, class Other2&gt;
      pair(
         const pair&lt;Other1, Other2&gt;&amp; _Right
      );
   };
</code></pre>
<p>ich versteh den code, allerding frag ich mich für wa die typedef notwendig sind?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/216797/frage-zu-template-am-beispiel-std-pair</link><generator>RSS for Node</generator><lastBuildDate>Sun, 11 Oct 2026 02:52:28 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/216797.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 28 Jun 2008 15:07:05 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Frage zu Template am beispiel std::pair on Sat, 28 Jun 2008 15:07:05 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>hab mal den template code (header) aus der hife kopiert:</p>
<pre><code class="language-cpp">template&lt;class Type1, class Type2&gt;
   struct pair 
   {
   typedef Type1 first_type;
   typedef Type2 second_type
   Type1 first;
   Type2 second;
   pair( );
   pair(
      const Type1&amp; __Val1, 
      const Type2&amp; __Val2
   );
   template&lt;class Other1, class Other2&gt;
      pair(
         const pair&lt;Other1, Other2&gt;&amp; _Right
      );
   };
</code></pre>
<p>ich versteh den code, allerding frag ich mich für wa die typedef notwendig sind?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1537518</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1537518</guid><dc:creator><![CDATA[LehrlingC++]]></dc:creator><pubDate>Sat, 28 Jun 2008 15:07:05 GMT</pubDate></item><item><title><![CDATA[Reply to Frage zu Template am beispiel std::pair on Sat, 28 Jun 2008 15:11:47 GMT]]></title><description><![CDATA[<p>der ist nur dazu da, damit man im nachfolgenden first_type anstellen von Type1 benutzen kann, was da aber nicht gemacht wird.<br />
normalerweise, also wenn man es auch benutzt, ist so etwas auch nicht notwendig. eigentlich sogar störend, aber c++ lässt es zu.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1537523</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1537523</guid><dc:creator><![CDATA[ghorst]]></dc:creator><pubDate>Sat, 28 Jun 2008 15:11:47 GMT</pubDate></item><item><title><![CDATA[Reply to Frage zu Template am beispiel std::pair on Sat, 28 Jun 2008 15:20:50 GMT]]></title><description><![CDATA[<p>LehrlingC++ schrieb:</p>
<blockquote>
<p>ich versteh den code, allerding frag ich mich für wa die typedef notwendig sind?</p>
</blockquote>
<p>Der Standard definiert, wie die Schnittstelle dieser Klasse auszusehen hat, und zur Schnittstelle gehört eben dazu, dass diese Typaliase vorhanden sind. Dadurch kann man an anderer Stelle problemlos auf die Typen zugreifen, wenn man mit Templates arbeitet:</p>
<pre><code class="language-cpp">template &lt;typename TPair&gt;
void f(TPair const&amp; p) {
    // Schlüssel extrahieren:
    typename TPair::first_type key = p.first;
    // … mach was mit dem Schlüssel.
}

pair&lt;int, int&gt; x = make_pair(1, 2);
pair&lt;double, char&gt; y = make_pair(1.2, 'x');

f(x);
f(y);
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1537533</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1537533</guid><dc:creator><![CDATA[Konrad Rudolph]]></dc:creator><pubDate>Sat, 28 Jun 2008 15:20:50 GMT</pubDate></item><item><title><![CDATA[Reply to Frage zu Template am beispiel std::pair on Sat, 28 Jun 2008 15:25:39 GMT]]></title><description><![CDATA[<p>f u c k (edit: zweiter versuch: da man hier sonst love aufgedrückt bekommt.) ja, ich stehe neben mir. natürlich hat konrad recht. ich habe die überschrift ignoriert und nur deine klasse gelesen...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1537535</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1537535</guid><dc:creator><![CDATA[ghorst]]></dc:creator><pubDate>Sat, 28 Jun 2008 15:25:39 GMT</pubDate></item><item><title><![CDATA[Reply to Frage zu Template am beispiel std::pair on Sat, 28 Jun 2008 15:48:50 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">void f(TPair const&amp; p) { 
    // Schlüssel extrahieren: 
    typename TPair::first_type key = p.first; 
    // … mach was mit dem Schlüssel. 
}
</code></pre>
<p>d.h.</p>
<pre><code class="language-cpp">typename TPair::first key= p.first;
</code></pre>
<p>würde nich gehen?</p>
<p>woher wisst ihr das? ich will auch ein Buch <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f921.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--clown_face"
      title=":clown:"
      alt="🤡"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1537550</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1537550</guid><dc:creator><![CDATA[LehrlingC++]]></dc:creator><pubDate>Sat, 28 Jun 2008 15:48:50 GMT</pubDate></item><item><title><![CDATA[Reply to Frage zu Template am beispiel std::pair on Sat, 28 Jun 2008 15:51:29 GMT]]></title><description><![CDATA[<p>steh in dem buch von bjarne und auch im standard.</p>
<p>den draft des standards findest du auf der iso-seite. das buch von bjarne musst du käuflich erwerben. das ist allerdings beides nichts für anfänger.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1537552</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1537552</guid><dc:creator><![CDATA[ghorst]]></dc:creator><pubDate>Sat, 28 Jun 2008 15:51:29 GMT</pubDate></item></channel></rss>