parameter pack to inputRange

Erik Smith via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu May 5 22:57:44 PDT 2016


On Friday, 6 May 2016 at 05:20:50 UTC, Ali Çehreli wrote:
> On 05/05/2016 10:00 PM, Erik Smith wrote:
>> Is there an existing way to adapt a parameter pack to an input 
>> range? I
>> would like to construct an array with it.  Example:
>>
>> void run(A...) (A args) {
>>       Array!int a(toInputRange(args));
>> }
>>
>
> Just initialize an array with the arguments:
>
> void run(A...) (A args) {
>     writeln([args]);
> }
>
> Ali

That's allocating a dynamic array though, right?  It seems like 
there should be a non-GC adaptor for this purpose (especially 
since I'm using std.container.array).

erik



More information about the Digitalmars-d-learn mailing list