Contains a buffer object, and provides access to an instance of Header and contiguous storage for an arbitrary number of Element instances stored in that buffer.

    @frozen struct ManagedBufferPointer<Header, Element>

    For most purposes, the ManagedBuffer class can be used on its own. However, in cases where objects of various different classes must serve as storage, you need to also use ManagedBufferPointer.

    A valid buffer class is non-@objc, with no declared stored properties. Its deinit must destroy its stored Header and any constructed Elements.

    Example Buffer Class

     class MyBuffer<Element> { // non-@objc
       typealias Manager = ManagedBufferPointer<(Int, String), Element>
       deinit {
         Manager(unsafeBufferObject: self).withUnsafeMutablePointers {
           (pointerToHeader, pointerToElements) -> Void in
           pointerToElements.deinitialize(count: self.count)
           pointerToHeader.deinitialize(count: 1)
       // All properties are *computed* based on members of the Header
       var count: Int {
         return Manager(unsafeBufferObject: self).header.0
       var name: String {
         return Manager(unsafeBufferObject: self).header.1

    Citizens in Swift