Contents

withUnsafeMutableBytes(_:)

Calls a given closure with a raw pointer to the multiarray’s mutable storage.

Declaration

func withUnsafeMutableBytes<R>(_ body: (UnsafeMutableRawBufferPointer, [Int]) throws -> R) rethrows -> R

Parameters

  • body:

    A closure with an Unsafemutablerawbufferpointer parameter that points to the storage for the multiarray and its strides. This closure takes the following parameters:

    ptr

    The pointer to the buffer.

    strides

    The strides of the buffer in scalars. Note that this may be different from strides’s value prior to this method invocation.

Discussion

The buffer contains a collection of int32, float16, float32, or float64 values, depending on the multiarray’s data type. It may not store these scalar values contiguously; use strides to get the buffer layout.

See Also

Providing buffer access