<?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[Loeschen von doppelt vorhandenen Typen in Typelist geht nicht]]></title><description><![CDATA[<p>Hallo<br />
Jetzt habe ich ein Problem mit einem Typlisten Algorithmus: der Algorithmus &quot;NoDuplicates&quot; sollte alle doppelten Typen in einer Typelist entfernen. Das tut er in meinem Fall auch. Mehr oder weniger. Nur ersetzt er das zweite Aufkommen von &quot;unsigned char&quot; (dem doppelt vorhandenen Typ, wegen dem Replace vorher) nicht mit dem Nulltype oder loescht ihn ganz einfach aus der Liste (gewuenschtes Verhalten). Nein, er ersetzt ihn seltsamerweise mit &quot;unsigned int&quot;?!? Die Typliste wird auch nicht kuerzer (auch schon nachgetestet).</p>
<p>Der dazu erstellte Code von mir ist sehr an die Implementierung in Alexandrescu's Library &quot;Loki&quot; angelehnt <a href="http://loki-lib.sourceforge.net/" rel="nofollow">http://loki-lib.sourceforge.net/</a> Das Programm sollte problemlos kompilieren und laufen. Die Version ist wegen des hier einigermassen internationalen Umfeldes in englisch, ich hoffe, das is ok <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>
<p>Frage(n):<br />
Warum loescht NoDuplicates die entsprechenden doppelten Typen nicht einfach aus der Typelist, sondern ersetzt sie?<br />
Warum werden sie durch &quot;unsigned int&quot; ersetzt?</p>
<p>Danke im voraus, falls jemand hierfuer die Geduld faende. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f644.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_rolling_eyes"
      title=":rolling_eyes:"
      alt="🙄"
    /></p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;typeinfo&gt;

/*
  The null type
//*/
class NullType
{};

/*
  The typelist itself
//*/
template&lt; class T, class U &gt;
struct Typelist_
{
  typedef T 
    Head;

  typedef U 
    Tail;
};

/*
  Linearizing Typelist Creation

  ...a better alternative would use templates
//*/

// declaration for 4 elements 
template&lt; class T1, class T2 = NullType, class T3 = NullType, class T4 = NullType &gt;
struct Typelist
{
  typedef Typelist_&lt; T1, Typelist_&lt; T2, Typelist_&lt; T3, Typelist_&lt; T4, NullType &gt; &gt; &gt; &gt; 
    type_t;
};

// definitions.. 
template&lt; class T1 &gt;
struct Typelist&lt; T1, NullType, NullType, NullType &gt;
{
  typedef Typelist_&lt; T1, NullType &gt; 
    type_t;
};

template&lt; class T1, class T2 &gt;
struct Typelist&lt; T1, T2, NullType, NullType &gt;
{
  typedef Typelist_&lt; T1, Typelist_&lt; T2, NullType &gt; &gt; 
    type_t;
};

template&lt; class T1, class T2, class T3 &gt;
struct Typelist&lt; T1, T2, T3, NullType &gt;
{
  typedef Typelist_&lt; T1, Typelist_&lt; T2, Typelist_&lt; T3, NullType &gt; &gt; &gt; 
    type_t;
};

/*
  Typelist algorithms live in the TL namespace
//*/
namespace TL
{
  /*
    Indexed Access

    The declaration of a template for an indexed operation would look like this:
      template&lt; class TList, unsigned int index &gt; struct TypeAt;

    Algorithm:
    IF TList is non-null and i is zero, then Result is the head of TList
    ELSE
      IF TList is non-null and index i is nonzero, then Result is obtained by applying
        TypeAt to the tail of TList and i-1
      ELSE there is an out-of-bound access that translates into a compile-time error

    Usage:
    TL::TypeAt&lt; MyTypelist, idx &gt;::Result variable;
  //*/

  // basic template form
  template&lt; class TList, unsigned int index &gt; 
  struct TypeAt;

  // head
  template&lt; class Head, class Tail &gt; 
  struct TypeAt&lt; Typelist_&lt; Head, Tail &gt;, 0 &gt;
  {
    typedef Head 
      Result;
  };

  // any element
  template&lt; class Head, class Tail, unsigned int i &gt;
  struct TypeAt&lt; Typelist_&lt; Head, Tail &gt;, i&gt;
  {
    typedef typename TypeAt&lt; Tail, i-1 &gt;::Result 
      Result;
  };

  /*
    Erasing a Type from a Typelist

    Algorithm:
    IF TList is NullType, then Result is NullType
    ELSE 
      IF T is the same as TList::Head, then Result is TList::Tail
      ELSE Result is a typelist having TList::Head as its head 
        and the result of applying Erase to TList::Tail and T as its tail

    Usage:
    typedef Erase&lt; MyTypelist, TypeToErase &gt;::Result MyNewTypelist;    
  //*/
  template&lt; class TList, class T &gt; 
  struct Erase; 

  template&lt; class T &gt;
  struct Erase&lt; NullType, T &gt;
  {
    typedef NullType 
      Result;
  };

  template&lt; class T, class Tail &gt;
  struct Erase&lt; Typelist_&lt; T, Tail &gt;, T &gt;
  {
    typedef Tail 
      Result;
  };

  template&lt; class Head, class Tail, class T &gt;
  struct Erase&lt; Typelist_&lt; Head, Tail &gt; , T &gt;
  {
    typedef Typelist_&lt; Head, typename Erase&lt; Tail, T &gt;::Result &gt;
      Result;
  };

  /*
    No Duplicates

    Algorithm:
    IF TList is NullType, then Result is NullType
    ELSE
      Apply NoDuplicates to TList::Tail, obtaining a temporary typelist L1
      Apply Erase to L1 and TList:Head. Obtain L2 as the result
      Result is a typelist whose head is TList::Head and whose tail is L2

    Usage:
    typedef TL::NoDuplicates&lt; MyTypelist &gt;::Result MyTypelistWithoutDuplicates;
  //*/
  template&lt; class TList &gt; 
  struct NoDuplicates;

  template&lt;&gt;
  struct NoDuplicates&lt; NullType &gt;
  {
    typedef NullType 
      Result;
  };

  template&lt; class Head, class Tail &gt;
  struct NoDuplicates&lt; Typelist_&lt; Head, Tail &gt; &gt;
  {
  private:
    typedef typename NoDuplicates&lt; Tail &gt;::Result 
      L1;

    typedef typename Erase&lt; L1, Head &gt;::Result 
      L2;

  public:
    typedef Typelist_&lt; Head, L2 &gt; 
      Result;
  };

  /*
    Replacing an Element in Typelist

    Algorithm:
    IF TList is NullType, then Result is NullType
    ELSE 
      IF the head of the typelist TList is T, then Result is a typelist 
        with U as its head and TList::Tail as its tail
      ELSE Result is a typelist with TList::Head as its head and the 
        result of applying Replace to TList, T, and U as its tail.

    Usage:
    typedef TL::Replace&lt; MyTypelist, TypeToRemove, TypeToReplace &gt;::Result MyReplacedTypelist;
  //*/  
  template&lt; class TList, class T, class U &gt;
  struct Replace;

  template&lt; class T, class U &gt;
  struct Replace&lt; NullType, T, U &gt;
  {
    typedef NullType 
      Result;
  };

  template&lt; class T, class Tail, class U &gt;
  struct Replace&lt; Typelist_&lt; T, Tail &gt;, T, U &gt;
  {
    typedef Typelist_&lt; U, Tail &gt; 
      Result;
  };

  template&lt; class Head, class Tail, class T, class U &gt;
  struct Replace&lt; Typelist_&lt; Head, Tail &gt;, T, U &gt;
  {
    typedef Typelist_&lt; Head, typename Replace&lt; Tail, T, U &gt;::Result&gt; 
      Result;
  };
}

/*
  main..
//*/
int main()
{
  using namespace std;

  // init a TYPELIST_3 - old style: avoid MACROs!
  cout &lt;&lt; &quot;init a typelist\n&quot;;
  typedef Typelist&lt; unsigned char, unsigned short int, unsigned int &gt;::type_t 
    MyTypelist_t;
  cout &lt;&lt; endl;

  // replace elements
  cout &lt;&lt; &quot;REPLACE ELEMENTS\n&quot;;
  cout &lt;&lt; &quot;second element is \&quot;unsigned int\&quot;?\t: &quot; 
       &lt;&lt; ((typeid(unsigned int) == typeid(TL::TypeAt&lt; MyTypelist_t, 2 &gt;::Result)) ? &quot;true&quot; : &quot;false&quot;) 
       &lt;&lt; endl;
  cout &lt;&lt; &quot;replacing elmenet \&quot;unsigned int\&quot; with \&quot;unsigned char\&quot;...&quot;;
  typedef TL::Replace&lt; MyTypelist_t, unsigned int, unsigned char &gt;::Result 
    MyReplacedTypelist_t;  
  cout &lt;&lt; &quot;done.\n&quot;;
  cout &lt;&lt; &quot;now second element is \&quot;unsigned char\&quot;?\t: &quot; 
       &lt;&lt; ((typeid(unsigned char) == typeid(TL::TypeAt&lt; MyReplacedTypelist_t, 2 &gt;::Result)) ? &quot;true&quot; : &quot;false&quot;) 
       &lt;&lt; endl;  
  cout &lt;&lt; endl;

  // erase duplicates 
  cout &lt;&lt; &quot;ERASE DUPLICATES\n&quot;;
  cout &lt;&lt; &quot;content before:\n&quot;
       &lt;&lt; &quot;\t\&quot;unsigned char\&quot;\t\t: &quot; 
       &lt;&lt; ((typeid(TL::TypeAt&lt; MyReplacedTypelist_t, 0 &gt;::Result) == typeid(unsigned char)) ? &quot;true&quot; : &quot;false&quot;) 
       &lt;&lt; endl
       &lt;&lt; &quot;\t\&quot;unsigned short int\&quot;\t: &quot; 
       &lt;&lt; ((typeid(TL::TypeAt&lt; MyReplacedTypelist_t, 1 &gt;::Result) ==  typeid(unsigned short int)) ? &quot;true&quot; : &quot;false&quot;) 
       &lt;&lt; endl
       &lt;&lt; &quot;\t\&quot;unsigned char\&quot;\t\t: &quot; 
       &lt;&lt; ((typeid(TL::TypeAt&lt; MyReplacedTypelist_t, 2 &gt;::Result) == typeid(unsigned char)) ? &quot;true&quot; : &quot;false&quot;)
       &lt;&lt; endl;
  cout &lt;&lt; &quot;do no duplicates...&quot;;
  typedef TL::NoDuplicates&lt; MyTypelist_t &gt;::Result 
    MyTypelistWithoutDuplicates_t;
  cout &lt;&lt; &quot;done.\n&quot;;
  cout &lt;&lt; &quot;content after:\n&quot;
       &lt;&lt; &quot;\t\&quot;unsigned char\&quot;\t\t: &quot; 
       &lt;&lt; ((typeid(TL::TypeAt&lt; MyTypelistWithoutDuplicates_t, 0 &gt;::Result) == typeid(unsigned char)) ? &quot;true&quot; : &quot;false&quot;) 
       &lt;&lt; endl
       &lt;&lt; &quot;\t\&quot;unsigned short int\&quot;\t: &quot; 
       &lt;&lt; ((typeid(TL::TypeAt&lt; MyTypelistWithoutDuplicates_t, 1 &gt;::Result) ==  typeid(unsigned short int)) ? &quot;true&quot; : &quot;false&quot;) 
       &lt;&lt; endl
       &lt;&lt; &quot;\t\&quot;unsigned char\&quot;\t\t: &quot; 
       &lt;&lt; ((typeid(TL::TypeAt&lt; MyTypelistWithoutDuplicates_t, 2 &gt;::Result) == typeid(unsigned char)) ? &quot;true&quot; : &quot;false&quot;)
       &lt;&lt; endl;

  cout &lt;&lt; &quot;\nPROBLEM: replaced by \&quot;unsigned int\&quot;\n&quot;
       &lt;&lt; &quot;\&quot;unsigned int\&quot;\t\t: &quot; 
       &lt;&lt; ((typeid(TL::TypeAt&lt; MyTypelistWithoutDuplicates_t, 2 &gt;::Result) == typeid(unsigned int)) ? &quot;true&quot; : &quot;false&quot;)
       &lt;&lt; endl;
  cout &lt;&lt; endl;

  cout &lt;&lt; &quot;READY.\n&quot;;
  return 0;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/227623/loeschen-von-doppelt-vorhandenen-typen-in-typelist-geht-nicht</link><generator>RSS for Node</generator><lastBuildDate>Tue, 29 Sep 2026 19:22:15 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/227623.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 17 Nov 2008 21:14:55 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Loeschen von doppelt vorhandenen Typen in Typelist geht nicht on Mon, 17 Nov 2008 21:14:55 GMT]]></title><description><![CDATA[<p>Hallo<br />
Jetzt habe ich ein Problem mit einem Typlisten Algorithmus: der Algorithmus &quot;NoDuplicates&quot; sollte alle doppelten Typen in einer Typelist entfernen. Das tut er in meinem Fall auch. Mehr oder weniger. Nur ersetzt er das zweite Aufkommen von &quot;unsigned char&quot; (dem doppelt vorhandenen Typ, wegen dem Replace vorher) nicht mit dem Nulltype oder loescht ihn ganz einfach aus der Liste (gewuenschtes Verhalten). Nein, er ersetzt ihn seltsamerweise mit &quot;unsigned int&quot;?!? Die Typliste wird auch nicht kuerzer (auch schon nachgetestet).</p>
<p>Der dazu erstellte Code von mir ist sehr an die Implementierung in Alexandrescu's Library &quot;Loki&quot; angelehnt <a href="http://loki-lib.sourceforge.net/" rel="nofollow">http://loki-lib.sourceforge.net/</a> Das Programm sollte problemlos kompilieren und laufen. Die Version ist wegen des hier einigermassen internationalen Umfeldes in englisch, ich hoffe, das is ok <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>
<p>Frage(n):<br />
Warum loescht NoDuplicates die entsprechenden doppelten Typen nicht einfach aus der Typelist, sondern ersetzt sie?<br />
Warum werden sie durch &quot;unsigned int&quot; ersetzt?</p>
<p>Danke im voraus, falls jemand hierfuer die Geduld faende. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f644.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_rolling_eyes"
      title=":rolling_eyes:"
      alt="🙄"
    /></p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;typeinfo&gt;

/*
  The null type
//*/
class NullType
{};

/*
  The typelist itself
//*/
template&lt; class T, class U &gt;
struct Typelist_
{
  typedef T 
    Head;

  typedef U 
    Tail;
};

/*
  Linearizing Typelist Creation

  ...a better alternative would use templates
//*/

// declaration for 4 elements 
template&lt; class T1, class T2 = NullType, class T3 = NullType, class T4 = NullType &gt;
struct Typelist
{
  typedef Typelist_&lt; T1, Typelist_&lt; T2, Typelist_&lt; T3, Typelist_&lt; T4, NullType &gt; &gt; &gt; &gt; 
    type_t;
};

// definitions.. 
template&lt; class T1 &gt;
struct Typelist&lt; T1, NullType, NullType, NullType &gt;
{
  typedef Typelist_&lt; T1, NullType &gt; 
    type_t;
};

template&lt; class T1, class T2 &gt;
struct Typelist&lt; T1, T2, NullType, NullType &gt;
{
  typedef Typelist_&lt; T1, Typelist_&lt; T2, NullType &gt; &gt; 
    type_t;
};

template&lt; class T1, class T2, class T3 &gt;
struct Typelist&lt; T1, T2, T3, NullType &gt;
{
  typedef Typelist_&lt; T1, Typelist_&lt; T2, Typelist_&lt; T3, NullType &gt; &gt; &gt; 
    type_t;
};

/*
  Typelist algorithms live in the TL namespace
//*/
namespace TL
{
  /*
    Indexed Access

    The declaration of a template for an indexed operation would look like this:
      template&lt; class TList, unsigned int index &gt; struct TypeAt;

    Algorithm:
    IF TList is non-null and i is zero, then Result is the head of TList
    ELSE
      IF TList is non-null and index i is nonzero, then Result is obtained by applying
        TypeAt to the tail of TList and i-1
      ELSE there is an out-of-bound access that translates into a compile-time error

    Usage:
    TL::TypeAt&lt; MyTypelist, idx &gt;::Result variable;
  //*/

  // basic template form
  template&lt; class TList, unsigned int index &gt; 
  struct TypeAt;

  // head
  template&lt; class Head, class Tail &gt; 
  struct TypeAt&lt; Typelist_&lt; Head, Tail &gt;, 0 &gt;
  {
    typedef Head 
      Result;
  };

  // any element
  template&lt; class Head, class Tail, unsigned int i &gt;
  struct TypeAt&lt; Typelist_&lt; Head, Tail &gt;, i&gt;
  {
    typedef typename TypeAt&lt; Tail, i-1 &gt;::Result 
      Result;
  };

  /*
    Erasing a Type from a Typelist

    Algorithm:
    IF TList is NullType, then Result is NullType
    ELSE 
      IF T is the same as TList::Head, then Result is TList::Tail
      ELSE Result is a typelist having TList::Head as its head 
        and the result of applying Erase to TList::Tail and T as its tail

    Usage:
    typedef Erase&lt; MyTypelist, TypeToErase &gt;::Result MyNewTypelist;    
  //*/
  template&lt; class TList, class T &gt; 
  struct Erase; 

  template&lt; class T &gt;
  struct Erase&lt; NullType, T &gt;
  {
    typedef NullType 
      Result;
  };

  template&lt; class T, class Tail &gt;
  struct Erase&lt; Typelist_&lt; T, Tail &gt;, T &gt;
  {
    typedef Tail 
      Result;
  };

  template&lt; class Head, class Tail, class T &gt;
  struct Erase&lt; Typelist_&lt; Head, Tail &gt; , T &gt;
  {
    typedef Typelist_&lt; Head, typename Erase&lt; Tail, T &gt;::Result &gt;
      Result;
  };

  /*
    No Duplicates

    Algorithm:
    IF TList is NullType, then Result is NullType
    ELSE
      Apply NoDuplicates to TList::Tail, obtaining a temporary typelist L1
      Apply Erase to L1 and TList:Head. Obtain L2 as the result
      Result is a typelist whose head is TList::Head and whose tail is L2

    Usage:
    typedef TL::NoDuplicates&lt; MyTypelist &gt;::Result MyTypelistWithoutDuplicates;
  //*/
  template&lt; class TList &gt; 
  struct NoDuplicates;

  template&lt;&gt;
  struct NoDuplicates&lt; NullType &gt;
  {
    typedef NullType 
      Result;
  };

  template&lt; class Head, class Tail &gt;
  struct NoDuplicates&lt; Typelist_&lt; Head, Tail &gt; &gt;
  {
  private:
    typedef typename NoDuplicates&lt; Tail &gt;::Result 
      L1;

    typedef typename Erase&lt; L1, Head &gt;::Result 
      L2;

  public:
    typedef Typelist_&lt; Head, L2 &gt; 
      Result;
  };

  /*
    Replacing an Element in Typelist

    Algorithm:
    IF TList is NullType, then Result is NullType
    ELSE 
      IF the head of the typelist TList is T, then Result is a typelist 
        with U as its head and TList::Tail as its tail
      ELSE Result is a typelist with TList::Head as its head and the 
        result of applying Replace to TList, T, and U as its tail.

    Usage:
    typedef TL::Replace&lt; MyTypelist, TypeToRemove, TypeToReplace &gt;::Result MyReplacedTypelist;
  //*/  
  template&lt; class TList, class T, class U &gt;
  struct Replace;

  template&lt; class T, class U &gt;
  struct Replace&lt; NullType, T, U &gt;
  {
    typedef NullType 
      Result;
  };

  template&lt; class T, class Tail, class U &gt;
  struct Replace&lt; Typelist_&lt; T, Tail &gt;, T, U &gt;
  {
    typedef Typelist_&lt; U, Tail &gt; 
      Result;
  };

  template&lt; class Head, class Tail, class T, class U &gt;
  struct Replace&lt; Typelist_&lt; Head, Tail &gt;, T, U &gt;
  {
    typedef Typelist_&lt; Head, typename Replace&lt; Tail, T, U &gt;::Result&gt; 
      Result;
  };
}

/*
  main..
//*/
int main()
{
  using namespace std;

  // init a TYPELIST_3 - old style: avoid MACROs!
  cout &lt;&lt; &quot;init a typelist\n&quot;;
  typedef Typelist&lt; unsigned char, unsigned short int, unsigned int &gt;::type_t 
    MyTypelist_t;
  cout &lt;&lt; endl;

  // replace elements
  cout &lt;&lt; &quot;REPLACE ELEMENTS\n&quot;;
  cout &lt;&lt; &quot;second element is \&quot;unsigned int\&quot;?\t: &quot; 
       &lt;&lt; ((typeid(unsigned int) == typeid(TL::TypeAt&lt; MyTypelist_t, 2 &gt;::Result)) ? &quot;true&quot; : &quot;false&quot;) 
       &lt;&lt; endl;
  cout &lt;&lt; &quot;replacing elmenet \&quot;unsigned int\&quot; with \&quot;unsigned char\&quot;...&quot;;
  typedef TL::Replace&lt; MyTypelist_t, unsigned int, unsigned char &gt;::Result 
    MyReplacedTypelist_t;  
  cout &lt;&lt; &quot;done.\n&quot;;
  cout &lt;&lt; &quot;now second element is \&quot;unsigned char\&quot;?\t: &quot; 
       &lt;&lt; ((typeid(unsigned char) == typeid(TL::TypeAt&lt; MyReplacedTypelist_t, 2 &gt;::Result)) ? &quot;true&quot; : &quot;false&quot;) 
       &lt;&lt; endl;  
  cout &lt;&lt; endl;

  // erase duplicates 
  cout &lt;&lt; &quot;ERASE DUPLICATES\n&quot;;
  cout &lt;&lt; &quot;content before:\n&quot;
       &lt;&lt; &quot;\t\&quot;unsigned char\&quot;\t\t: &quot; 
       &lt;&lt; ((typeid(TL::TypeAt&lt; MyReplacedTypelist_t, 0 &gt;::Result) == typeid(unsigned char)) ? &quot;true&quot; : &quot;false&quot;) 
       &lt;&lt; endl
       &lt;&lt; &quot;\t\&quot;unsigned short int\&quot;\t: &quot; 
       &lt;&lt; ((typeid(TL::TypeAt&lt; MyReplacedTypelist_t, 1 &gt;::Result) ==  typeid(unsigned short int)) ? &quot;true&quot; : &quot;false&quot;) 
       &lt;&lt; endl
       &lt;&lt; &quot;\t\&quot;unsigned char\&quot;\t\t: &quot; 
       &lt;&lt; ((typeid(TL::TypeAt&lt; MyReplacedTypelist_t, 2 &gt;::Result) == typeid(unsigned char)) ? &quot;true&quot; : &quot;false&quot;)
       &lt;&lt; endl;
  cout &lt;&lt; &quot;do no duplicates...&quot;;
  typedef TL::NoDuplicates&lt; MyTypelist_t &gt;::Result 
    MyTypelistWithoutDuplicates_t;
  cout &lt;&lt; &quot;done.\n&quot;;
  cout &lt;&lt; &quot;content after:\n&quot;
       &lt;&lt; &quot;\t\&quot;unsigned char\&quot;\t\t: &quot; 
       &lt;&lt; ((typeid(TL::TypeAt&lt; MyTypelistWithoutDuplicates_t, 0 &gt;::Result) == typeid(unsigned char)) ? &quot;true&quot; : &quot;false&quot;) 
       &lt;&lt; endl
       &lt;&lt; &quot;\t\&quot;unsigned short int\&quot;\t: &quot; 
       &lt;&lt; ((typeid(TL::TypeAt&lt; MyTypelistWithoutDuplicates_t, 1 &gt;::Result) ==  typeid(unsigned short int)) ? &quot;true&quot; : &quot;false&quot;) 
       &lt;&lt; endl
       &lt;&lt; &quot;\t\&quot;unsigned char\&quot;\t\t: &quot; 
       &lt;&lt; ((typeid(TL::TypeAt&lt; MyTypelistWithoutDuplicates_t, 2 &gt;::Result) == typeid(unsigned char)) ? &quot;true&quot; : &quot;false&quot;)
       &lt;&lt; endl;

  cout &lt;&lt; &quot;\nPROBLEM: replaced by \&quot;unsigned int\&quot;\n&quot;
       &lt;&lt; &quot;\&quot;unsigned int\&quot;\t\t: &quot; 
       &lt;&lt; ((typeid(TL::TypeAt&lt; MyTypelistWithoutDuplicates_t, 2 &gt;::Result) == typeid(unsigned int)) ? &quot;true&quot; : &quot;false&quot;)
       &lt;&lt; endl;
  cout &lt;&lt; endl;

  cout &lt;&lt; &quot;READY.\n&quot;;
  return 0;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1616190</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1616190</guid><dc:creator><![CDATA[Fabeltier]]></dc:creator><pubDate>Mon, 17 Nov 2008 21:14:55 GMT</pubDate></item><item><title><![CDATA[Reply to Loeschen von doppelt vorhandenen Typen in Typelist geht nicht on Tue, 18 Nov 2008 19:22:16 GMT]]></title><description><![CDATA[<p>*push*</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1616745</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1616745</guid><dc:creator><![CDATA[Fabeltier]]></dc:creator><pubDate>Tue, 18 Nov 2008 19:22:16 GMT</pubDate></item><item><title><![CDATA[Reply to Loeschen von doppelt vorhandenen Typen in Typelist geht nicht on Wed, 19 Nov 2008 13:29:34 GMT]]></title><description><![CDATA[<p>ACHTUNG! DU WIRST DICH ÄRGERN!</p>
<pre><code class="language-cpp">typedef TL::NoDuplicates&lt; MyTypelist_t &gt;::Result MyTypelistWithoutDuplicates_t;
</code></pre>
<p>Sollte wohl eher so lauten:</p>
<pre><code class="language-cpp">typedef TL::NoDuplicates&lt; MyReplacedTypelist_t &gt;::Result MyTypelistWithoutDuplicates_t;
</code></pre>
<p>Sonst wäre das Resultat absolut korrekt. Das kommt von schlechter Übersicht in deiner Mainfunktion. Gib deinem Code mehr platz, lagere Dinge in Funktionen aus. Zum Beispiel so ein Code könnte dir auch weiterhelfen, hat es zumindest mir:</p>
<pre><code class="language-cpp">template&lt;typename TList&gt;
struct DoOutput;

template&lt;typename Head&gt;
struct DoOutput&lt;Typelist_&lt;Head, NullType&gt; &gt;
{
	DoOutput()
	{
		std::cout &lt;&lt; typeid(Head).name() &lt;&lt; std::endl;
	}
};

template&lt;typename Head, typename Tail&gt;
struct DoOutput&lt;Typelist_&lt;Head, Tail&gt; &gt;
{
private:
	typedef DoOutput&lt;Tail&gt; NextOutput;

public:
	DoOutput()
	{
		std::cout &lt;&lt; typeid(Head).name() &lt;&lt; std::endl;
		NextOutput();
	}
};

// Verwendung:
DoOutput&lt;MyTypelist_t&gt;();
</code></pre>
<p>Dann steht in der Mainfunktion zum Beispiel nur noch das folgende:</p>
<pre><code class="language-cpp">int main() 
{
	typedef Typelist&lt; unsigned char, unsigned short int, unsigned int &gt;::type_t MyTypelist_t;

	DoOutput&lt;MyTypelist_t&gt;();
	std::cout &lt;&lt; std::endl;

	typedef TL::Replace&lt; MyTypelist_t, unsigned int, unsigned char &gt;::Result MyReplacedTypelist_t;

	DoOutput&lt;MyReplacedTypelist_t&gt;();
	std::cout &lt;&lt; std::endl;

	typedef TL::NoDuplicates&lt; MyReplacedTypelist_t &gt;::Result MyTypelistWithoutDuplicates_t;

	DoOutput&lt;MyTypelistWithoutDuplicates_t&gt;();
	std::cout &lt;&lt; std::endl;

	test::wait(&quot;PAUSE&quot;);

	return 0;
}
</code></pre>
<p>Grüssli</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1617094</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1617094</guid><dc:creator><![CDATA[Dravere]]></dc:creator><pubDate>Wed, 19 Nov 2008 13:29:34 GMT</pubDate></item><item><title><![CDATA[Reply to Loeschen von doppelt vorhandenen Typen in Typelist geht nicht on Thu, 20 Nov 2008 11:20:26 GMT]]></title><description><![CDATA[<p>Super, danke - aergern.. nicht wirklich <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>
<p>Nja, der Code wurde irgendwie zunaechst fuer andere Dinge benutzt, dann kam dieses Problem auf, dann wollte ich auf Laenge testen, dann doch die Types direkt vergleichen, dann dies, dann jenes... schliesslich kam obiger zusammengeflickter Code heraus, mit einer entsprechenden Unleserlichkeit die selbst einfache Schreibfehler unkenntlich macht. Ich denke das ist v.a. bei der Arbeit mit Templates und deren ausschweifender Schreibweise ein Riesenfallstrick oder zumindest kann es sehr nervig sein und man muss um so mehr aufpassen die Uebersicht zu bewahren. Danke! Wird mir eine Lehre sein, hoffe ich!! <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1617651</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1617651</guid><dc:creator><![CDATA[Fabeltier]]></dc:creator><pubDate>Thu, 20 Nov 2008 11:20:26 GMT</pubDate></item></channel></rss>