unsafeLoadUnaligned(fromUncheckedByteOffset:as:)
Returns a new instance of the given type, constructed from the raw memory at the specified offset.
Declaration
func unsafeLoadUnaligned<T>(fromUncheckedByteOffset offset: Int, as type: T.Type) -> T where T : BitwiseCopyableParameters
- offset:
The offset from this pointer, in bytes.
offsetmust be nonnegative. 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. The returned instance isn’t associated with the value in the range of memory referenced by this pointer.
Discussion
The memory at this pointer plus offset must be initialized to T or another type that is layout compatible with T.
This is an unsafe operation. This function does not validate the bounds of the memory access, and failure to meet the preconditions above may produce an invalid value of T.