template with more than one tuple parameter

Simen Kjaeraas simen.kjaras at gmail.com
Sat Jul 28 09:47:23 PDT 2012


On Sat, 28 Jul 2012 18:17:14 +0200, Zhenya <zheny at list.ru> wrote:

> Why do not D allow templates with more than one tuple
> parameters,at the
> same time that C++11 support it:

Well, Walter implemented type tuples with automatic flattening,
back when dinosaurs roamed the earth (we now help people who have
questions). We've lived with that decision since then, and though
there are times when a non-flattening system would have been nice,
it's easy enough to work around:

template NonFlatteningTuple( T... ) {
     alias T types;
}

template Foo( T, U )  {
     // Do things with T.types and U.types here
}

Foo!( NonFlatteningTuple!(int, float), NonFlatteningTuple!() );

-- 
Simen


More information about the Digitalmars-d-learn mailing list