<!--
{
  "availability" : [
    "iOS: 12.2.0 -",
    "iPadOS: 12.2.0 -",
    "macCatalyst: 12.2.0 -",
    "macOS: 10.14.4 -",
    "tvOS: 12.2.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 5.2.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Swift",
  "identifier" : "/documentation/Swift/OutputSpan/init(buffer:initializedCount:)-vie3",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Swift"
    ],
    "preciseIdentifier" : "s:s10OutputSpanV6buffer16initializedCountAByxGs5SliceVySryxGGh_Sitcfc"
  },
  "title" : "init(buffer:initializedCount:)"
}
-->

# init(buffer:initializedCount:)

Unsafely create an OutputSpan over partly-initialized memory.

```
init(buffer: borrowing Slice<UnsafeMutableBufferPointer<Element>>, initializedCount: Int)
```

## Parameters

`buffer`

a slice of an `UnsafeMutableBufferPointer` to be initialized

`initializedCount`

the number of initialized elements
at the beginning of `buffer`.

## Discussion

The memory in `buffer` must remain valid throughout the lifetime
of the newly-created `OutputSpan`. Its prefix must contain
`initializedCount` initialized instances, followed by uninitialized
memory. The default value of `initializedCount` is 0, representing
the common case of a completely uninitialized `buffer`.

---

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)