On Saturday, 15 November 2014 at 03:47:25 UTC, Steven Schveighoffer wrote:
Note, there isn't any generic way to say "give me a copy of this range, as the same type." array is probably the best you will get. Just make sure you call it *before* you sort, unless you want both ranges sorted :)

-Steve

Does this mean that r.array is better than my current

auto sorted(R)(const R r) if (isInputRange!R &&
                              !(isArray!R))
{
    alias E = ElementType!R;
    import std.algorithm: sort, copy;
auto s = new E[r.length]; // TODO length is probably not available here
    r.copy(s);
    s.sort;
    return s;
}

at https://github.com/nordlow/justd/blob/master/sort_ex.d#L117

?

Reply via email to