UnsafeRawPointer
extension UnsafeRawPointer
-
Returns a new instance of the given type, constructed from the raw memory at the specified offset. The type to be loaded must be a trivial type.
The memory at this pointer plus offset does not need to be properly aligned for accessing T. It must be initialized to T or another type that is layout compatible with T. The returned instance is unassociated with the value in the memory referenced by this pointer.
Declaration
Swift
public func unalignedLoad<T>(fromByteOffset offset: Int = 0, as type: T.Type) -> T where T : FixedWidthInteger
Parameters
offset
The offset from this pointer, in bytes.
offset
. The default is zero.type
The type of the instance to create.
Return Value
A new instance of type T, read from the raw bytes at offset.