On Sunday, 23 March 2014 at 14:58:53 UTC, bearophile wrote:
Nordlöw:

Is there a convenicene function for assigning an empty dynamic array of a given type to a variable?

   cast(int[])[];

                   _range = cast(D[])[];

If the variable is already typed, you can use [] otherwise you can use cast(T)[] or (T[]).init to avoid casts.

Bye,
bearophile

Ok. Enough for now...but Is there a way to avoid this array special handling:

                static if (isArray!R)
                    _range = (D[]).init;
                else
                    _range = R(); // return empty range

through some initializer expression for _range that covers both

    R()

and

    (D[]).init

?

Reply via email to