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>(UnsafePointer<T>
) Creates a new raw pointer from the given typed pointer.
init?<T>(UnsafePointer<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?(UnsafeMutableRawPointer?
) Creates a new raw pointer from the given mutable raw pointer.
init<T>(UnsafeMutablePointer<T>
) Creates a new raw pointer from the given typed pointer.
init(UnsafeMutableRawPointer
) Creates a new raw pointer from the given mutable raw pointer.
Instance members
func advanced(by: Int
) -> UnsafeRawPointer func alignedDown<T>(for: T.Type
) -> UnsafeRawPointer Obtain the preceding pointer properly aligned to store a value of type
T
.func alignedDown(toMultipleOf: Int
) -> UnsafeRawPointer Obtain the preceding pointer whose bit pattern is a multiple of
alignment
.func alignedUp<T>(for: T.Type
) -> UnsafeRawPointer Obtain the next pointer properly aligned to store a value of type
T
.func alignedUp(toMultipleOf: Int
) -> UnsafeRawPointer Obtain the next pointer whose bit pattern is a multiple of
alignment
.func assumingMemoryBound<T>(to: T.Type
) -> UnsafePointer<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
) -> UnsafePointer<T> Binds the memory to the specified type and returns a typed pointer to the bound memory.
func deallocate(
) Deallocates the previously allocated memory block referenced by this pointer.
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 withMemoryRebound<T, E, Result>(to: T.Type, capacity: Int, (UnsafePointer<T>)
throws Executes the given closure while temporarily binding memory to the specified number of instances of type
T
.