Tuple DIP

Timon Gehr timon.gehr at gmx.ch
Tue Feb 20 03:23:44 UTC 2018


On 20.02.2018 01:57, Timothee Cour wrote:
> On Mon, Feb 19, 2018 at 4:05 PM, Timon Gehr via Digitalmars-d
> <digitalmars-d at puremagic.com> wrote:
>> On 20.02.2018 00:53, Timothee Cour wrote:
>>>
>> Sure! Also, this:
>>
>> void main(string[] args){
>>      enforce(args.length==5, "Invalid args");
>>      auto (infile, colname, repl, outfile) = args[1..5].unpack;
>>      // ...
>> }
> 
> 
> how does that latter example work?
> 

IFTI. unpack could have the following overload:

auto unpack(size_t n,T)(T[n] args){
     return 
mixin("tuple("~iota(n).map!(i=>text("args[",i,"]")).join(",")~")");
}


More information about the Digitalmars-d mailing list