parameter pack to inputRange

Alex Parrill via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon May 9 07:33:44 PDT 2016


On Sunday, 8 May 2016 at 14:11:31 UTC, Ali Çehreli wrote:
> I like Alex Parrill's only() solution but it allocates a 
> dynamic array as well by doing the equivalent of [args] in the 
> guts of its implementation.

No it does not.

The constructor does `this.data = [values];`, but `this.data` is 
a fixed-sized array, which is stored in the structure itself. No 
allocation needs to happen (it should be the same as the foreach 
loop in your implementation).

You guys are just re-inventing `only`.


More information about the Digitalmars-d-learn mailing list