[Issue 15982] std.array.array treats dynamic arrays as input ranges and allocates new memory

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Mon May 2 04:24:17 PDT 2016


--- Comment #3 from ag0aep6g at gmail.com ---
(In reply to sigod from comment #2)
> It's meaningless for dynamic arrays.

Currently std.array.array guarantees one level of duplication. So when I call
it on an int[], I can rely on the new array being independent from the original
one. I can alter elements without affecting the original. I can cast it to
immutable(int)[] without running into undefined behavior when the original is

I'm not saying that this is the best behavior for a function called "array",
but that's how it's documented and how it works. Changing it now would be a
serious breaking change.


More information about the Digitalmars-d-bugs mailing list