Instance Methodswift 6.0.1Swift
load(fromByteOffset:as:)
Returns a new instance of the given type, constructed from the raw memory at the specified offset.
func load<T>(fromByteOffset offset: Int = 0, as type: T.Type) -> T
Parameters
Returns
A new instance of type T
, read from the raw bytes at offset
. The returned instance is memory-managed and unassociated with the value in the memory referenced by this pointer.
The memory at this pointer plus offset
must be properly aligned for accessing T
and initialized to T
or another type that is layout compatible with T
.
Other members in extension
Typealiases
Type members
init?<T>(UnsafeMutablePointer<T>?
) Creates a new raw pointer from the given typed pointer.
init<T>(UnsafeMutablePointer<T>
) Creates a new raw pointer from the given typed pointer.
init(mutating: UnsafeRawPointer
) Creates a new mutable raw pointer from the given immutable raw pointer.
init?(mutating: UnsafeRawPointer?
) Creates a new mutable raw pointer from the given immutable raw pointer.
static func allocate(byteCount: Int, alignment: Int
) -> UnsafeMutableRawPointer Allocates uninitialized memory with the specified size and alignment.
Show obsolete interfaces (1)
Hide obsolete interfaces
Instance members
func advanced(by: Int
) -> UnsafeMutableRawPointer func alignedDown<T>(for: T.Type
) -> UnsafeMutableRawPointer Obtain the preceding pointer properly aligned to store a value of type
T
.func alignedDown(toMultipleOf: Int
) -> UnsafeMutableRawPointer Obtain the preceding pointer whose bit pattern is a multiple of
alignment
.func alignedUp<T>(for: T.Type
) -> UnsafeMutableRawPointer Obtain the next pointer properly aligned to store a value of type
T
.func alignedUp(toMultipleOf: Int
) -> UnsafeMutableRawPointer Obtain the next pointer whose bit pattern is a multiple of
alignment
.func assumingMemoryBound<T>(to: T.Type
) -> UnsafeMutablePointer<T> Returns a typed pointer to the memory referenced by this pointer, assuming that the memory is already bound to the specified type.
func bindMemory<T>(to: T.Type, capacity: Int
) -> UnsafeMutablePointer<T> Binds the memory to the specified type and returns a typed pointer to the bound memory.
func copyMemory(from: UnsafeRawPointer, byteCount: Int
) Copies the specified number of bytes from the given raw pointer’s memory into this pointer’s memory.
func deallocate(
) Deallocates the previously allocated memory block referenced by this pointer.
func initializeMemory<T>(as: T.Type, from: UnsafePointer<T>, count: Int
) -> UnsafeMutablePointer<T> Initializes the memory referenced by this pointer with the values starting at the given pointer, binds the memory to the values’ type, and returns a typed pointer to the initialized memory.
func initializeMemory<T>(as: T.Type, repeating: T, count: Int
) -> UnsafeMutablePointer<T> Initializes the memory referenced by this pointer with the given value, binds the memory to the value’s type, and returns a typed pointer to the initialized memory.
func initializeMemory<T>(as: T.Type, to: consuming T
) -> UnsafeMutablePointer<T> Initializes the memory referenced by this pointer with the given value, binds the memory to the value’s type, and returns a typed pointer to the initialized memory.
func loadUnaligned<T>(fromByteOffset: Int, as: T.Type
) -> T Returns a new instance of the given type, constructed from the raw memory at the specified offset.
func loadUnaligned<T>(fromByteOffset: Int, as: T.Type
) -> T Returns a new instance of the given type, constructed from the raw memory at the specified offset.
func moveInitializeMemory<T>(as: T.Type, from: UnsafeMutablePointer<T>, count: Int
) -> UnsafeMutablePointer<T> Initializes the memory referenced by this pointer with the values starting at the given pointer, binds the memory to the values’ type, deinitializes the source memory, and returns a typed pointer to the newly initialized memory.
func storeBytes<T>(of: T, toByteOffset: Int, as: T.Type
) Stores the given value’s bytes into raw memory at the specified offset.
func storeBytes<T>(of: T, toByteOffset: Int, as: T.Type
) Stores the given value’s bytes into raw memory at the specified offset.
func withMemoryRebound<T, E, Result>(to: T.Type, capacity: Int, (UnsafeMutablePointer<T>)
throws Executes the given closure while temporarily binding memory to the specified number of instances of type
T
.
Show obsolete interfaces (5)
Hide obsolete interfaces
var customPlaygroundQuickLook: _PlaygroundQuickLook
func copyBytes(from: UnsafeRawPointer, count: Int
) func deallocate(bytes: Int, alignedTo: Int
) func initializeMemory<T>(as: T.Type, at: Int, count: Int, to: T
) -> UnsafeMutablePointer<T> func initializeMemory<C>(as: C.Element.Type, from: C
) -> UnsafeMutablePointer<C.Element>