Can `UnsafeMutablePonter<T>.moveInitialize(from:count:)` be used with overlapping source and destination?

I have a buffer with elements ?ABCD (? - unitialized), and I want to move first 3 to get ABC?D. Can I use UnsafeMutablePonter<T>.moveInitialize(from:count:) for that? Is the following code a valid usage of this method?

let ptr: UnsafeMutablePonter<T> = ...
ptr.moveInitialize(from: ptr.advanced(by: 1), count: 3)

That works. The implementation checks for overlapping ranges. It will process this case in forward order, deinitializing each source element as it goes.

Terms of Service

Privacy Policy

Cookie Policy