<?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[map mit template struct]]></title><description><![CDATA[<p>Mich würde folgendes intressieren:</p>
<pre><code class="language-cpp">class mapStruct{
private:
   template&lt;class T&gt;
   struct mapStruct{
      double a;
      T b;
      value* next};
   std::map&lt;int,mapStruct&gt; mapB;
public:
   template&lt;class T&gt;
   setValue(int key,int a,T b);
   template&lt;class T&gt;
   T getValue();
}
</code></pre>
<p>Kann man so etwas irgendwie machen? Dies soll dann in einer map eine verkette Liste darstellen <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/topic/293582/map-mit-template-struct</link><generator>RSS for Node</generator><lastBuildDate>Sun, 16 Aug 2026 06:46:04 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/293582.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 06 Oct 2011 12:31:23 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to map mit template struct on Thu, 06 Oct 2011 12:31:23 GMT]]></title><description><![CDATA[<p>Mich würde folgendes intressieren:</p>
<pre><code class="language-cpp">class mapStruct{
private:
   template&lt;class T&gt;
   struct mapStruct{
      double a;
      T b;
      value* next};
   std::map&lt;int,mapStruct&gt; mapB;
public:
   template&lt;class T&gt;
   setValue(int key,int a,T b);
   template&lt;class T&gt;
   T getValue();
}
</code></pre>
<p>Kann man so etwas irgendwie machen? Dies soll dann in einer map eine verkette Liste darstellen <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2128023</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2128023</guid><dc:creator><![CDATA[Beobachter01]]></dc:creator><pubDate>Thu, 06 Oct 2011 12:31:23 GMT</pubDate></item><item><title><![CDATA[Reply to map mit template struct on Thu, 06 Oct 2011 12:47:38 GMT]]></title><description><![CDATA[<p>Meinst du so?</p>
<pre><code class="language-cpp">template &lt;class T&gt; class mapStruct
{
private:
 struct mapStructNode
 {
   T b;
   T* next
 };
 std::map&lt;int,mapStructNode&gt; mapB;
public:
  setValue(int key, T b);
  T getValue(int key);
};
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2128033</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2128033</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Thu, 06 Oct 2011 12:47:38 GMT</pubDate></item><item><title><![CDATA[Reply to map mit template struct on Thu, 06 Oct 2011 12:58:05 GMT]]></title><description><![CDATA[<p>Sorry ich habe ausversehen die Klasse und die Struktur mit gleichen Namen benannt!</p>
<pre><code class="language-cpp">class mapClass{
private:
   template&lt;class T&gt;
   struct mapStruct{
      double a;
      T b;
      value* next};
   std::map&lt;int,mapStruct&gt; mapB;
public:
   template&lt;class T&gt;
   setValue(int key,int a,T b);
   template&lt;class T&gt;
   T getValue();
}
</code></pre>
<p>So wie du es geschrieben hast, muss ich beim aufrufen immer mapClass&lt;int&gt;::setValue(...) schreiben, das ich aber vermeiden möchte! Es soll später ein Singleton darstellen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2128044</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2128044</guid><dc:creator><![CDATA[Beobachter01]]></dc:creator><pubDate>Thu, 06 Oct 2011 12:58:05 GMT</pubDate></item><item><title><![CDATA[Reply to map mit template struct on Thu, 06 Oct 2011 13:07:37 GMT]]></title><description><![CDATA[<p>Beobachter01 schrieb:</p>
<blockquote>
<p>So wie du es geschrieben hast, muss ich beim aufrufen immer mapClass&lt;int&gt;::setValue(...) schreiben,</p>
</blockquote>
<p>Typedef.</p>
<p>Außerdem wäre es gut, alle Informationen rauszurücken. Singleton ist ja schon einmal eine ganz neue Information. Das ganze Design kommt mir nämlich äußerst merkwürdig vor.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2128049</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2128049</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Thu, 06 Oct 2011 13:07:37 GMT</pubDate></item><item><title><![CDATA[Reply to map mit template struct on Thu, 06 Oct 2011 13:34:07 GMT]]></title><description><![CDATA[<p>Es war nur eine Frage ob so etwas möglich wäre. Im nachhinein könnte daraus ein Singleton erstellt werden um es als eine gemeinsame Speichercontainer zu verwenden.</p>
<p>Sorry die Frage wird dumm sein aber, wo soll ich den typedef ansetzen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2128063</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2128063</guid><dc:creator><![CDATA[Beobachter01]]></dc:creator><pubDate>Thu, 06 Oct 2011 13:34:07 GMT</pubDate></item><item><title><![CDATA[Reply to map mit template struct on Thu, 06 Oct 2011 14:09:47 GMT]]></title><description><![CDATA[<p>Beobachter01 schrieb:</p>
<blockquote>
<pre><code class="language-cpp">class mapClass{
private:
   template&lt;class T&gt;
   struct mapStruct{
      double a;
      T b;
      value* next};
   std::map&lt;int,mapStruct&gt; mapB;
public:
   template&lt;class T&gt;
   setValue(int key,int a,T b);
   template&lt;class T&gt;
   T getValue();
}
</code></pre>
<p>Kann man so etwas irgendwie machen?</p>
</blockquote>
<p>&quot;so etwas irgendwie&quot; ist bei diesem Beispiel von ungültigem C++ nicht gerade besonders präzise.</p>
<p>Beobachter01 schrieb:</p>
<blockquote>
<p>Dies soll dann in einer map eine verkette Liste darstellen</p>
</blockquote>
<p>Aha.</p>
<p>Gefällt Dir das?</p>
<pre><code class="language-cpp">struct dings {
  double a;
  boost::any o;
  dings* next;
};

map&lt;int,dings&gt; zuordnung;
</code></pre>
<p>oder das?</p>
<pre><code class="language-cpp">struct dings_base {
  virtual ~dings_base() = 0;
  double a;
  dings_base* next;
};

dings_base::~dings_base() {}

template&lt;class T&gt;
struct dings_mit_T : dings_base {
  T obj;
  ...
};

boost::ptr_map&lt;int,dings_base&gt; zuordnung;
</code></pre>
<p>Beobachter01 schrieb:</p>
<blockquote>
<p>Es war nur eine Frage ob so etwas möglich wäre. [...] als eine gemeinsame Speichercontainer zu verwenden.</p>
</blockquote>
<p>Wozu? Was soll das bringen? Welches Problem willst Du damit lösen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2128064</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2128064</guid><dc:creator><![CDATA[krümelkacker]]></dc:creator><pubDate>Thu, 06 Oct 2011 14:09:47 GMT</pubDate></item><item><title><![CDATA[Reply to map mit template struct on Thu, 06 Oct 2011 13:44:44 GMT]]></title><description><![CDATA[<p>Es mir nur eingefallen und ich wollte es testen, aber ist nicht gelungen. Ich habe bis dato, einen großen Bogen von boost-lib gemacht und wollte gewisse Dinge mit C++-Standardbib. lösen.<br />
Danke euch!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2128070</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2128070</guid><dc:creator><![CDATA[Beobachter01]]></dc:creator><pubDate>Thu, 06 Oct 2011 13:44:44 GMT</pubDate></item><item><title><![CDATA[Reply to map mit template struct on Thu, 06 Oct 2011 13:56:52 GMT]]></title><description><![CDATA[<p>Beobachter01 schrieb:</p>
<blockquote>
<p>Sorry die Frage wird dumm sein aber, wo soll ich den typedef ansetzen?</p>
</blockquote>
<p>Noch nirgendwo, weil du noch gar keine statischen Memberfunktionen hast. Aber wenn du den Klassennamen brauchst und nicht immer die Templateargumente ausschreiben möchtest, dann machst du eben einen typedef:</p>
<pre><code class="language-cpp">template&lt;typename T&gt; struct stupid_global_variable
{
 static int data;
};

typedef stupid_global_variable&lt;int&gt; my_int;

template&lt;&gt; int my_int::data = 0;

int main()
{
  my_int::data = 5;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2128074</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2128074</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Thu, 06 Oct 2011 13:56:52 GMT</pubDate></item></channel></rss>