[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 05:08:24 PDT 2016
https://issues.dlang.org/show_bug.cgi?id=15982
--- Comment #6 from ag0aep6g at gmail.com ---
(In reply to ag0aep6g from comment #5)
> Here's a little generic function that relies on std.array.array's current
> behavior:
> ----
> immutable(ElementType!R)[] toImmutableArray(R)(R range)
> if (isInputRange!R && !hasIndirections!(ElementType!R))
> {
> import std.array: array;
> import std.exception: assumeUnique;
> return assumeUnique(range.array);
> }
> ----
Missing imports:
----
import std.range: ElementType, isInputRange;
import std.traits: hasIndirections;
----
--
More information about the Digitalmars-d-bugs
mailing list