---
title: "withUnsafeMutablePointerToElements(_:)"
framework: swift
role: symbol
role_heading: Instance Method
path: "swift/managedbufferpointer/withunsafemutablepointertoelements(_:)"
---

# withUnsafeMutablePointerToElements(_:)

Call body with an UnsafeMutablePointer to the Element storage.

## Declaration

```swift
func withUnsafeMutablePointerToElements<E, R>(_ body: (UnsafeMutablePointer<Element>) throws(E) -> R) throws(E) -> R where E : Error, R : ~Copyable
```

## Discussion

Discussion note: This pointer is valid only for the duration of the call to body. The caller is responsible for ensuring that the buffer is not being accessed anyone else while performing this call.

## See Also

### Accessing Buffer Contents

- [withUnsafeMutablePointerToHeader(_:)](swift/managedbufferpointer/withunsafemutablepointertoheader(_:).md)
- [withUnsafeMutablePointers(_:)](swift/managedbufferpointer/withunsafemutablepointers(_:).md)
