<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.10.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Swift",
  "identifier" : "/documentation/Swift/ManagedBufferPointer/withUnsafeMutablePointerToElements(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Swift"
    ],
    "preciseIdentifier" : "s:s20ManagedBufferPointerVsRi__rlE017withUnsafeMutableC10ToElementsyqd_0_qd_0_Spyq_Gqd__YKXEqd__YKs5ErrorRd__Ri_d_0_r0_lF"
  },
  "title" : "withUnsafeMutablePointerToElements(_:)"
}
-->

# withUnsafeMutablePointerToElements(_:)

Call `body` with an `UnsafeMutablePointer` to the `Element`
storage.

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

## 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.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)