<?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[Typelist -&amp;gt; hirarchie]]></title><description><![CDATA[<p>Ich hab eine typelist die mehrere klassentypen enthällt, nehmen wir mal folgendes beispiel:</p>
<pre><code>// the building block for typelists of any length
// -&gt; IMPORTANT: every typelist hast to end with a NullType
// -&gt; defines nested types:
//      head (first element, a non-typelist type by convention)
//      tail (second element, can be another typelist)
template &lt;class T, class U&gt;
struct Typelist{
   typedef T head;
   typedef U hail;
};

// some example types
class a{
public: int a_ : 11;
};
class b{
public: int b_ : 12;
};
class c{
public: int c_ : 13;
};

// build the typelist
typedef TypeList&lt;a, TypeList&lt;b, TypeList&lt;c, NullType&gt; &gt; &gt; list_type;
</code></pre>
<p>jetzt möchte ich eine klasse schreiben, welche von allen typen in der typelist erbt, ich will also anstatt:</p>
<pre><code>class MyClass : public a, b, c{
};
</code></pre>
<p>folgendes schreiben können:</p>
<pre><code>class MyClass : public MagicHirarchieGenerator&lt;type_list&gt;{
};
</code></pre>
<p>Es geht dabei eher um das prinzip, wie man etwas solches schreiben könnte und weniger um den anwendungszweg in einem fertigen programm.<br />
Es ist halt mehr eine spielerei, eine selbstgestellte aufgabe, bei der ich nicht weiter komme. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/topic/314019/typelist-gt-hirarchie</link><generator>RSS for Node</generator><lastBuildDate>Sun, 02 Aug 2026 03:54:48 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/314019.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 17 Feb 2013 20:07:36 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Typelist -&amp;gt; hirarchie on Sun, 17 Feb 2013 20:07:36 GMT]]></title><description><![CDATA[<p>Ich hab eine typelist die mehrere klassentypen enthällt, nehmen wir mal folgendes beispiel:</p>
<pre><code>// the building block for typelists of any length
// -&gt; IMPORTANT: every typelist hast to end with a NullType
// -&gt; defines nested types:
//      head (first element, a non-typelist type by convention)
//      tail (second element, can be another typelist)
template &lt;class T, class U&gt;
struct Typelist{
   typedef T head;
   typedef U hail;
};

// some example types
class a{
public: int a_ : 11;
};
class b{
public: int b_ : 12;
};
class c{
public: int c_ : 13;
};

// build the typelist
typedef TypeList&lt;a, TypeList&lt;b, TypeList&lt;c, NullType&gt; &gt; &gt; list_type;
</code></pre>
<p>jetzt möchte ich eine klasse schreiben, welche von allen typen in der typelist erbt, ich will also anstatt:</p>
<pre><code>class MyClass : public a, b, c{
};
</code></pre>
<p>folgendes schreiben können:</p>
<pre><code>class MyClass : public MagicHirarchieGenerator&lt;type_list&gt;{
};
</code></pre>
<p>Es geht dabei eher um das prinzip, wie man etwas solches schreiben könnte und weniger um den anwendungszweg in einem fertigen programm.<br />
Es ist halt mehr eine spielerei, eine selbstgestellte aufgabe, bei der ich nicht weiter komme. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2299559</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2299559</guid><dc:creator><![CDATA[gamer8o4]]></dc:creator><pubDate>Sun, 17 Feb 2013 20:07:36 GMT</pubDate></item><item><title><![CDATA[Reply to Typelist -&amp;gt; hirarchie on Sun, 17 Feb 2013 20:49:46 GMT]]></title><description><![CDATA[<p>Typlisten wie von dir gezeigt sind sowas von out. Gehe mit der Zeit und nimm C++11.</p>
<pre><code class="language-cpp">template &lt;typename... T&gt; struct typelist;
template &lt;typename&gt; class MyClass {};
template &lt;typename... T&gt; class MyClass&lt;typelist&lt;T...&gt;&gt; : T... {};

struct a{a(){std::cout &lt;&lt; &quot;construct a\n&quot;;}};
struct b{b(){std::cout &lt;&lt; &quot;construct b\n&quot;;}};
struct c{c(){std::cout &lt;&lt; &quot;construct c\n&quot;;}};

int main()
{
  using type_list = typelist&lt;a, b, c&gt;;
  MyClass&lt;type_list&gt; mc;
}

/* Ausgabe:
construct a
construct b
construct c
*/
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2299571</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2299571</guid><dc:creator><![CDATA[einself]]></dc:creator><pubDate>Sun, 17 Feb 2013 20:49:46 GMT</pubDate></item><item><title><![CDATA[Reply to Typelist -&amp;gt; hirarchie on Sun, 17 Feb 2013 21:00:49 GMT]]></title><description><![CDATA[<p>Gut, aus Nostalgiegründen die C++71-Version:</p>
<pre><code class="language-cpp">template &lt;typename T&gt;
struct MagicHirarchieGenerator;
template &lt;typename H, typename T&gt;
struct MagicHirarchieGenerator&lt;TypeList&lt;H, T&gt; &gt; : H, MagicHirarchieGenerator&lt;T&gt; {};
template &lt;&gt;
struct MagicHirarchieGenerator&lt;NullType&gt; {};
</code></pre>
<p>hail! (Nicht falsch verstehen, das Wort steht so in gamer8o4s Code)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2299575</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2299575</guid><dc:creator><![CDATA[einself]]></dc:creator><pubDate>Sun, 17 Feb 2013 21:00:49 GMT</pubDate></item><item><title><![CDATA[Reply to Typelist -&amp;gt; hirarchie on Sun, 17 Feb 2013 21:12:06 GMT]]></title><description><![CDATA[<blockquote>
<p>Typlisten wie von dir gezeigt sind sowas von out. Gehe mit der Zeit und nimm C++11.</p>
</blockquote>
<p>oh mein gott, gut das ich das gefragt habe <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="😃"
    /> jetzt schreibe ich seit 2 tagen an algorithmen für typelisten und jetzt sagst du mir, dass es in c++11 dafür variadische templates gibt...<br />
hab das gerade mal ausprobiert, aber anscheinend kapiert das mein &quot;visual studio 2012 express desktop&quot; nicht. Ich lade mal die updates runter und melde mich nochmal <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2299579</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2299579</guid><dc:creator><![CDATA[gamer8o4]]></dc:creator><pubDate>Sun, 17 Feb 2013 21:12:06 GMT</pubDate></item><item><title><![CDATA[Reply to Typelist -&amp;gt; hirarchie on Sun, 17 Feb 2013 21:37:09 GMT]]></title><description><![CDATA[<p>gibt immernoch einen fehler, wie gesagt ich hab es mit &quot;visual studio 2012 express for desktop&quot; ausgetestet, und da dass einer der neusten compiler ist , sollte es doch eigentlich funktionieren, aber naja... klappt nicht <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=":/"
      alt="😕"
    /></p>
<pre><code>error C2143: syntax error : missing ',' before '...'
</code></pre>
<pre><code>template&lt;typename... Args&gt; struct SomeStruct {
};
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2299591</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2299591</guid><dc:creator><![CDATA[gamer8o4]]></dc:creator><pubDate>Sun, 17 Feb 2013 21:37:09 GMT</pubDate></item><item><title><![CDATA[Reply to Typelist -&amp;gt; hirarchie on Thu, 12 Jun 2014 10:43:04 GMT]]></title><description><![CDATA[<p>...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2299594</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2299594</guid><dc:creator><![CDATA[Swordfish]]></dc:creator><pubDate>Thu, 12 Jun 2014 10:43:04 GMT</pubDate></item><item><title><![CDATA[Reply to Typelist -&amp;gt; hirarchie on Mon, 18 Feb 2013 16:10:23 GMT]]></title><description><![CDATA[<pre><code>#include &lt;iostream&gt;
using namespace std;

//#include &lt;delta\include.h&gt;
//using namespace delta;

template &lt;typename... T&gt; struct typelist; 
template &lt;typename&gt; class MyClass {}; 
template &lt;typename... T&gt; class MyClass&lt;typelist&lt;T...&gt; &gt; : T... {}; 

struct a{a(){std::cout &lt;&lt; &quot;construct a\n&quot;;}}; 
struct b{b(){std::cout &lt;&lt; &quot;construct b\n&quot;;}}; 
struct c{c(){std::cout &lt;&lt; &quot;construct c\n&quot;;}}; 

int main() { 
  typedef typelist&lt;a,b,c&gt; type_list;
  MyClass&lt;type_list&gt; mc; 

  getchar();
}
</code></pre>
<p>fehler:</p>
<blockquote>
<p>1&gt;------ Build started: Project: AppConsole, Configuration: Debug x64 ------<br />
1&gt; main.cpp<br />
1&gt;main.cpp(7): error C2143: syntax error : missing ',' before '...'<br />
1&gt;main.cpp(9): error C2143: syntax error : missing ',' before '...'<br />
1&gt;main.cpp(9): error C2065: 'T' : undeclared identifier<br />
1&gt;main.cpp(9): error C2143: syntax error : missing ';' before '{'<br />
1&gt;main.cpp(11): error C2143: syntax error : missing ';' before '{'<br />
1&gt;main.cpp(12): error C2143: syntax error : missing ';' before '{'<br />
1&gt;main.cpp(13): error C2143: syntax error : missing ';' before '{'<br />
1&gt;main.cpp(15): error C2143: syntax error : missing ';' before '{'<br />
1&gt;main.cpp(16): error C2065: 'a' : undeclared identifier<br />
1&gt;main.cpp(16): error C2065: 'b' : undeclared identifier<br />
1&gt;main.cpp(16): error C2065: 'c' : undeclared identifier<br />
1&gt;main.cpp(16): error C2977: 'typelist' : too many template arguments<br />
1&gt; main.cpp(7) : see declaration of 'typelist'<br />
1&gt;main.cpp(17): error C2065: 'type_list' : undeclared identifier<br />
1&gt;main.cpp(17): error C2923: 'MyClass' : 'type_list' is not a valid template type argument for parameter '&lt;unnamed-symbol&gt;'<br />
1&gt;main.cpp(20): error C2143: syntax error : missing ';' before '}'<br />
1&gt;main.cpp(21): error C2143: syntax error : missing ';' before '}'<br />
1&gt;main.cpp(21): fatal error C1004: unexpected end-of-file found<br />
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========</p>
</blockquote>
]]></description><link>https://www.c-plusplus.net/forum/post/2299745</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2299745</guid><dc:creator><![CDATA[gamer8o4]]></dc:creator><pubDate>Mon, 18 Feb 2013 16:10:23 GMT</pubDate></item><item><title><![CDATA[Reply to Typelist -&amp;gt; hirarchie on Mon, 18 Feb 2013 16:17:20 GMT]]></title><description><![CDATA[<p>Anleitung beachtet?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2299747</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2299747</guid><dc:creator><![CDATA[camper]]></dc:creator><pubDate>Mon, 18 Feb 2013 16:17:20 GMT</pubDate></item><item><title><![CDATA[Reply to Typelist -&amp;gt; hirarchie on Mon, 18 Feb 2013 16:55:45 GMT]]></title><description><![CDATA[<p>update gedownloaded<br />
update installiert<br />
pc neugestartet<br />
neues projekt erstellt (win32 console application)<br />
debug win32<br />
code kopiert<br />
code kompeliert<br />
FEHLER</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2299753</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2299753</guid><dc:creator><![CDATA[gamer8o4]]></dc:creator><pubDate>Mon, 18 Feb 2013 16:55:45 GMT</pubDate></item><item><title><![CDATA[Reply to Typelist -&amp;gt; hirarchie on Mon, 18 Feb 2013 16:57:48 GMT]]></title><description><![CDATA[<blockquote>
<p>Instructions</p>
<p>After downloading and installing the program, you can launch Visual Studio 2012, load your C++ project and you can <strong>switch to the new compilers. We recommend you create a separate project configuration from menu Build &gt; Configuration Manager by duplicating your existing configuration and then follow the steps below: 1.Open Project Property Pages (Alt+F7 under the Visual C++ mappings or right-click on the project in Solution Explorer) 2.From the ‘General’ tab, change ‘Platform toolset’ from ‘Visual Studio 2012 (v110)’ to ‘Microsoft Visual C++ Compiler Nov 2012 CTP (v120_CTP_Nov)’ and close the Property Pages 3.Launch a full rebuild of your project</strong></p>
</blockquote>
]]></description><link>https://www.c-plusplus.net/forum/post/2299754</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2299754</guid><dc:creator><![CDATA[camper]]></dc:creator><pubDate>Mon, 18 Feb 2013 16:57:48 GMT</pubDate></item><item><title><![CDATA[Reply to Typelist -&amp;gt; hirarchie on Mon, 18 Feb 2013 17:27:52 GMT]]></title><description><![CDATA[<p><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="🤡"
    /> sorry, nicht richtig gelesen, klappt....</p>
<p>eine frage aber noch nebenbei, lohnt nicht dafür ein thema aufzumachen <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
<pre><code>class c{
  int i;
  int getInt() const{
     return i;
  }
};
</code></pre>
<p>ist der zugriff auf i threadsafe? oder kann es zu fehlern kommen, wenn gleichzeitig ein anderer thread die variable ändert?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2299758</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2299758</guid><dc:creator><![CDATA[gamer8o4]]></dc:creator><pubDate>Mon, 18 Feb 2013 17:27:52 GMT</pubDate></item><item><title><![CDATA[Reply to Typelist -&amp;gt; hirarchie on Mon, 18 Feb 2013 17:29:59 GMT]]></title><description><![CDATA[<p>In solchen Situationen kann es immer zu Fehlern kommen. Thread Synchronisation ist hier definitiv erforderlich.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2299759</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2299759</guid><dc:creator><![CDATA[äääääääääääää]]></dc:creator><pubDate>Mon, 18 Feb 2013 17:29:59 GMT</pubDate></item><item><title><![CDATA[Reply to Typelist -&amp;gt; hirarchie on Mon, 18 Feb 2013 17:31:26 GMT]]></title><description><![CDATA[<blockquote>
<p>In solchen Situationen kann es immer zu Fehlern kommen. Thread Synchronisation ist hier definitiv erforderlich.</p>
</blockquote>
<p>okay, habs geändert <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2299760</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2299760</guid><dc:creator><![CDATA[gamer8o4]]></dc:creator><pubDate>Mon, 18 Feb 2013 17:31:26 GMT</pubDate></item></channel></rss>