Instance Methodswift 6.0.3Swift

loadUnaligned(fromByteOffset:as:)

Returns a new instance of the given type, constructed from the raw memory at the specified offset.

func loadUnaligned<T>(fromByteOffset offset: Int = 0, as type: T.Type) -> T where T : BitwiseCopyable

Parameters

offset

The offset from this pointer, in bytes. offset must be nonnegative. The default is zero.

type

The type of the instance to create.

Returns

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.

This function only supports loading trivial types, and will trap if this precondition is not met. A trivial type does not contain any reference-counted property within its in-memory representation. The memory at this pointer plus offset must be laid out identically to the in-memory representation of T.