Struct Flattening

tama repeatedly at gmail.com
Wed Apr 22 00:23:05 PDT 2009


On Wed, 22 Apr 2009 14:50:58 +0900, tama <repeatedly at gmail.com> wrote:

> template flatten(T...)
> {
>      static if (T.length == 0)
>          alias T flatten;
>      else
>          alias TypeTuple!(FieldTypeTuple!(T[0]), flatten!(T[1..$]))  
> flatten;
> }

Fixed:

---
template flatten(T...)
{
     static if (T.length == 0)
         alias T flatten;
     else
         static if (is(T[0] == struct) && is(T[0] ==  
Joint!(typeof(T[0].tupleof))))
             alias TypeTuple!(typeof(T[0].tupleof), flatten!(T[1..$]))  
flatten;
         else
              alias TypeTuple!(T[0], flatten!(T[1..$])) flatten;
}
---

But look horrible.

-- 
tama <repeatedly at gmail.com>
http://profile.livedoor.com/repeatedly/
メンバー募集中
http://tpf.techtalk.jp/



More information about the Digitalmars-d mailing list