Summary: std.algorithm.copy overlapping array copy
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos

--- Comment #0 from Ellery Newcomer <> 2012-02-11 
11:52:25 PST ---
Way back in 2.054 you could use std.algorithm.copy in an overlapping copy,

copy(a[5 .. 10], a[4 .. 9]);

Fast forward a couple releases, and copy seems to be delegating to

a[4 .. 9] = a[5 .. 10];

in the interest of speed, but here overlapping copy is prohibited by spec and

I maintain that std.algorithm.copy should permit overlapping copy in the case
of arrays because

1: it is consistent with STL copy's semantics (see Note 2)

2: copy can still do an overlapping copy on non-array range types*, and failing
to do so on arrays is an inconsistency

If this behavior is desired, the docs should at least make mention of it. Also
note that if copy's behavior is reverted, it could be the solution for issue


auto a = make!(SList!int) ([1,2,3,4,5,6,7,8,9,10]);
auto r1 = a[];
auto r2 = a[];
writeln(a[]); // prints [2, 3, 4, 5, 6, 7, 8, 9, 10, 10]

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to