[swift-evolution] [Pitch] Add overrides with UnsafePointer sources to non-destructive copying methods on UnsafeMutablePointer

Rob Mayoff mayoff at dqd.com
Tue Feb 9 15:55:17 CST 2016

On Tue, Feb 9, 2016 at 10:53 AM, Janosch Hildebrand via swift-evolution <
swift-evolution at swift.org> wrote:

> Great question.
> I think it might be useful for a case where you don't know if you have
> overlapping ranges and use `assignBackwardFrom()` defensively?

You cannot use assignBackwardFrom "defensively" if you don't know whether
you have overlapping ranges. If the ranges overlap, and the source range
starts after the destination range, then assignBackwardFrom copies
destructively. (It overwrites some prefix of the source range with some
suffix of the source range, before copying the original prefix to the

It would be better to just have assignFrom behave like memmove (always
non-destructively) and not have assignBackwardFrom at all… but that's not
the point of this proposal.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160209/76642ad2/attachment.html>

More information about the swift-evolution mailing list