[Issue 7484] New: std.algorithm.copy overlapping array copy
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat Feb 11 11:52:27 PST 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7484
Summary: std.algorithm.copy overlapping array copy
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Severity: normal
Priority: P2
Component: Phobos
AssignedTo: nobody at puremagic.com
ReportedBy: ellery-newcomer at utulsa.edu
--- Comment #0 from Ellery Newcomer <ellery-newcomer at utulsa.edu> 2012-02-11 11:52:25 PST ---
Way back in 2.054 you could use std.algorithm.copy in an overlapping copy,
e.g.,
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
implementation.
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
1317.
*proof:
auto a = make!(SList!int) ([1,2,3,4,5,6,7,8,9,10]);
auto r1 = a[];
auto r2 = a[];
r2.popFront();
copy(r2,r1);
writeln(a[]); // prints [2, 3, 4, 5, 6, 7, 8, 9, 10, 10]
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list