---
title: ManagedBuffer
framework: swift
role: symbol
role_heading: Class
path: swift/managedbuffer
---

# ManagedBuffer

A class whose instances contain a property of type Header and raw storage for an array of Element, whose size is determined at instance creation.

## Declaration

```swift
class ManagedBuffer<Header, Element> where Element : ~Copyable
```

## Overview

Overview Note that the Element array is suitably-aligned raw memory. You are expected to construct and—if necessary—destroy objects there yourself, using the APIs on UnsafeMutablePointer<Element>. Typical usage stores a count and capacity in Header and destroys any live elements in the deinit of a subclass. note: Subclasses must not have any stored properties; any storage needed should be included in Header.

## Topics

### Instance Properties

- [capacity](swift/managedbuffer/capacity.md)
- [header](swift/managedbuffer/header.md)

### Instance Methods

- [withUnsafeMutablePointerToElements(_:)](swift/managedbuffer/withunsafemutablepointertoelements(_:).md)
- [withUnsafeMutablePointerToHeader(_:)](swift/managedbuffer/withunsafemutablepointertoheader(_:).md)
- [withUnsafeMutablePointers(_:)](swift/managedbuffer/withunsafemutablepointers(_:).md)

### Type Methods

- [create(minimumCapacity:makingHeaderWith:)](swift/managedbuffer/create(minimumcapacity:makingheaderwith:).md)

## See Also

### Buffer Implementation

- [ManagedBufferPointer](swift/managedbufferpointer.md)
