chunks equivalent with unpacking?

Andrej Mitrovic andrej.mitrovich at gmail.com
Wed Jul 31 10:57:30 PDT 2013


On 7/31/13, bearophile <bearophileHUGS at lycos.com> wrote:
> Those four variables x y z w influence the type of the foreach,
> while 4 is a run-time argument. This API can be used:
>
> foreach (x, y, z, w; arr.chunks!4)

Yeah it will have to be CT.

> A forward range like that seems easy to implement.

Can it? I've tried alternatively with opApply but it's problematic to
support both ref/non-ref argument versions.

I know there's been some sort of automatic unpacking feature recently
introduced (in 2.063 maybe?). Got an idea how you'd implement this
range?


More information about the Digitalmars-d-learn mailing list