forked from swiftlang/swift
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SE-0138: Add UnsafeRawBufferPointer and UnsafeMutableRawBufferPointer. (
swiftlang#4954) https://github.com/apple/swift-evolution/blob/master/proposals/0138-unsaferawbufferpointer.md Unsafe[Mutable]RawBufferPointer is a non-owning view over a region of memory as a Collection of bytes independent of the type of values held in that memory. Each 8-bit byte in memory is viewed as a `UInt8` value. Reads and writes on memory via `Unsafe[Mutable]RawBufferPointer` are untyped operations. Accessing this Collection's bytes does not bind the underlying memory to `UInt8`. The underlying memory must be bound to some trivial type whenever it is accessed via a typed operation. In addition to the `Collection` interface, the following methods from `Unsafe[Mutable]RawPointer`'s interface to raw memory are provided with debug mode bounds checks: `load(fromByteOffset:as:)`, `storeBytes(of:toByteOffset:as:)`, and `copyBytes(from:count:)`. This is only a view into memory and does not own the memory. Copying a value of type `UnsafeMutableRawBufferPointer` does not copy the underlying memory. Assigning an `Unsafe[Mutable]RawBufferPointer` into a value-based collection, such as `[UInt8]` copies bytes out of memory. Assigning into a subscript range of UnsafeMutableRawBufferPointer copies into memory.
- Loading branch information
Showing
6 changed files
with
864 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.