<?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[template Container]]></title><description><![CDATA[<p>Hi,</p>
<p>gibt es eine Möglichkeit, in einem Container durch eine Template-Klasse instanzierte Objekte mit unterschiedlichen Template-Parametern abzulegen?</p>
<p>In etwa so:</p>
<pre><code>template&lt;class T&gt; class c { T m_val; };
...
c&lt;int&gt; o1; c&lt;char&gt; o2;
list&lt;cVarset&lt;???&gt;&gt; l;
l.push_back(o1);
l.push_back(o2);
</code></pre>
<p>Alternative Vorschläge die dasselbe leisten, sind natürlich auch willkommen. Ziel ist, einen Container mit Objekten von unterschiedlichem Typ zu haben.</p>
<p>Ich möchte, wenn möglich, keine Liste mit Zeigern auf abstrakte Basisklassenobjekte verwenden.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/185060/template-container</link><generator>RSS for Node</generator><lastBuildDate>Thu, 24 Sep 2026 02:25:50 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/185060.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 21 Jun 2007 14:44:10 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to template Container on Thu, 21 Jun 2007 14:44:10 GMT]]></title><description><![CDATA[<p>Hi,</p>
<p>gibt es eine Möglichkeit, in einem Container durch eine Template-Klasse instanzierte Objekte mit unterschiedlichen Template-Parametern abzulegen?</p>
<p>In etwa so:</p>
<pre><code>template&lt;class T&gt; class c { T m_val; };
...
c&lt;int&gt; o1; c&lt;char&gt; o2;
list&lt;cVarset&lt;???&gt;&gt; l;
l.push_back(o1);
l.push_back(o2);
</code></pre>
<p>Alternative Vorschläge die dasselbe leisten, sind natürlich auch willkommen. Ziel ist, einen Container mit Objekten von unterschiedlichem Typ zu haben.</p>
<p>Ich möchte, wenn möglich, keine Liste mit Zeigern auf abstrakte Basisklassenobjekte verwenden.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1310762</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1310762</guid><dc:creator><![CDATA[Turing]]></dc:creator><pubDate>Thu, 21 Jun 2007 14:44:10 GMT</pubDate></item><item><title><![CDATA[Reply to template Container on Thu, 21 Jun 2007 14:45:52 GMT]]></title><description><![CDATA[<p>du könntest boost::any verwenden</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1310765</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1310765</guid><dc:creator><![CDATA[ronny]]></dc:creator><pubDate>Thu, 21 Jun 2007 14:45:52 GMT</pubDate></item><item><title><![CDATA[Reply to template Container on Thu, 21 Jun 2007 14:52:47 GMT]]></title><description><![CDATA[<p>Das ist eine Möglichkeit. Es darf jedoch nur die STL verwendet werden.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1310771</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1310771</guid><dc:creator><![CDATA[Turing]]></dc:creator><pubDate>Thu, 21 Jun 2007 14:52:47 GMT</pubDate></item><item><title><![CDATA[Reply to template Container on Thu, 21 Jun 2007 14:56:31 GMT]]></title><description><![CDATA[<p>Hi,</p>
<p>unterschiedliche Templateargumente =&gt; unterschiedliche Typen =&gt; geht nicht.<br />
Letztlich bleiben Dir nur &quot;wrapper-Konstrukte&quot; oder Laufzeit-Polymorphie über Basisklassenpointer.</p>
<p>Gruß,</p>
<p>Simon2.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1310779</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1310779</guid><dc:creator><![CDATA[Simon2]]></dc:creator><pubDate>Thu, 21 Jun 2007 14:56:31 GMT</pubDate></item><item><title><![CDATA[Reply to template Container on Thu, 21 Jun 2007 15:02:31 GMT]]></title><description><![CDATA[<blockquote>
<p>unterschiedliche Templateargumente =&gt; unterschiedliche Typen =&gt; geht nicht.<br />
Letztlich bleiben Dir nur &quot;wrapper-Konstrukte&quot; oder Laufzeit-Polymorphie über Basisklassenpointer.</p>
</blockquote>
<p>So etwas habe ich befürchtet.</p>
<p>Trotzdem Danke.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1310785</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1310785</guid><dc:creator><![CDATA[Turing]]></dc:creator><pubDate>Thu, 21 Jun 2007 15:02:31 GMT</pubDate></item><item><title><![CDATA[Reply to template Container on Thu, 21 Jun 2007 15:03:35 GMT]]></title><description><![CDATA[<p>Hi,</p>
<p>ach, sei froh, dass es nicht geht ... spart Dir eine Menge Ärger. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /></p>
<p>Gruß,</p>
<p>Simon2.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1310787</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1310787</guid><dc:creator><![CDATA[Simon2]]></dc:creator><pubDate>Thu, 21 Jun 2007 15:03:35 GMT</pubDate></item><item><title><![CDATA[Reply to template Container on Thu, 21 Jun 2007 16:38:09 GMT]]></title><description><![CDATA[<p>natürlich geht das. erstelle eine basisklasse ohne templates<br />
alle template-klassen leiten von dieser ab.<br />
dann kannst du pointer der basisklasse in der liste verwalten.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1310861</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1310861</guid><dc:creator><![CDATA[matimatiker]]></dc:creator><pubDate>Thu, 21 Jun 2007 16:38:09 GMT</pubDate></item><item><title><![CDATA[Reply to template Container on Fri, 22 Jun 2007 07:14:58 GMT]]></title><description><![CDATA[<p>matimatiker schrieb:</p>
<blockquote>
<p>natürlich geht das. erstelle eine basisklasse ohne templates<br />
alle template-klassen leiten von dieser ab.<br />
dann kannst du pointer der basisklasse in der liste verwalten.</p>
</blockquote>
<p>Zwar funktioniert Dein Vorschlag (weswegen ich den auch schon oben genannt habe) ... aber er passt nicht zu den Anforderungen des OPs. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /><br />
Er möchte explizit Compiletime-Polymorphie.</p>
<p>Ergo: Nein, das geht nicht.</p>
<p>Gruß,</p>
<p>Simon2.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1311185</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1311185</guid><dc:creator><![CDATA[Simon2]]></dc:creator><pubDate>Fri, 22 Jun 2007 07:14:58 GMT</pubDate></item></channel></rss>