Variadic template arguments unpacking

TommiT tommitissari at hotmail.com
Sat Jul 6 10:39:49 PDT 2013


On Saturday, 6 July 2013 at 17:29:36 UTC, Max Strakhov wrote:
>> The following should work though:
>>
>> printf( "...", ForEach!(tmp => tmp.c_str())(ForEach!(val => 
>> conv(val))(values).tuple).tuple );
>
> I had the same idea too, but couldn't make it work: compiler 
> complains about failed CTFE or something. On the other hand i 
> might do somethong wrong.

There were a couple of typos in _TypeMap. That's a correct one:

template _TypeMap(alias MAP, size_t N, TS...) {
   static if (N<TS.length)
       alias _TypeMap = _TypeMap!(MAP, N+1, TS[0..N], 
typeof(MAP(TS[N].init)), TS[N+1..$]);
   else
       alias _TypeMap = TS;
}

> Yeap, i personally find (as * 2)... awesome feature of c++.

Me too.


More information about the Digitalmars-d-learn mailing list