The title says it all – currently, std.array.array() is broken for (some) ranges of const/immutable elements. Fixing it is not hard, but the question is: Should it always return an array of (head-)mutable elements (since it allocates a copy anyway), or should it preserve constness of the element type?

The latter is maybe be the more »consistent« behavior, as the return type would always just be ElementType!Range[], but has the disadvantage that if you actually wanted to construct a mutable array from an immutable range, you'd have to cast away immutable (with unclear semantics), whereas getting an immutable array with the first implementation would just require assumeUnique() (for most ranges, array() is not going to be strongly pure).

I have a fix ready, but will hold back the pull request until it is clear which semantics we want.

Thanks,
David

Reply via email to