<!--
{
  "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/UnsafeBufferPointer",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "Swift"
    ],
    "preciseIdentifier" : "s:SR"
  },
  "title" : "UnsafeBufferPointer"
}
-->

# UnsafeBufferPointer

A nonowning collection interface to a buffer of
elements stored contiguously in memory.

```
@frozen struct UnsafeBufferPointer<Element> where Element : ~Copyable
```

## Overview

You can use an `UnsafeBufferPointer` instance in low level operations to eliminate
uniqueness checks and, in release mode, bounds checks. Bounds checks are
always performed in debug mode.

# UnsafeBufferPointer Semantics

An `UnsafeBufferPointer` instance is a view into memory and does not own the memory
that it references. Copying a value of type `UnsafeBufferPointer` does not copy the
instances stored in the underlying memory. However, initializing another
collection with an `UnsafeBufferPointer` instance copies the instances out of the
referenced memory and into the new collection.

## Relationships

### Conforms To

[`OperationParameter`](/documentation/Accelerate/BNNSGraph/Builder/OperationParameter)

[`BitwiseCopyable`](/documentation/Swift/BitwiseCopyable)

[`Collection`](/documentation/Swift/Collection)

[`ContiguousBytes`](/documentation/Foundation/ContiguousBytes)

[`AtomicRepresentable`](/documentation/Synchronization/AtomicRepresentable)

[`RandomAccessCollection`](/documentation/Swift/RandomAccessCollection)

[`Copyable`](/documentation/Swift/Copyable)

[`Escapable`](/documentation/Swift/Escapable)

[`ConvertibleToBytes`](/documentation/Swift/ConvertibleToBytes)

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

[`AccelerateBuffer`](/documentation/Accelerate/AccelerateBuffer)

[`DataProtocol`](/documentation/Foundation/DataProtocol)

[`Sequence`](/documentation/Swift/Sequence)

[`BidirectionalCollection`](/documentation/Swift/BidirectionalCollection)

---

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)