---
title: "withUnsafeMutablePointer(_:)"
framework: coreai
role: symbol
role_heading: Instance Method
path: "coreai/ndarray/mutableview/withunsafemutablepointer(_:)"
---

# withUnsafeMutablePointer(_:)

Invokes the provided closure with the backing data and memory layout of this view.

## Declaration

```swift
@export(implementation) mutating func withUnsafeMutablePointer<R, E>(_ body: (UnsafeMutablePointer<Element>, Span<Int>, Span<Int>) throws(E) -> R) throws(E) -> R where E : Error
```

## Return Value

Return Value The value returned by the closure.

## Discussion

Discussion body: The closure to be invoked with a mutable pointer to the first element, as well as shape and strides of the view. note: This function is intended for situations where you may not be working with contiguous layouts, and as such cannot use contiguousElements. You are responsible for reading the strides passed in when indexing the backing data. If the view has an interleaveLayout, the strides for that dimension are block strides and must be interpreted accordingly — see NDArray.InterleaveLayout.
