Skip to content

MetadataPack

tevelee edited this page Jul 25, 2026 · 1 revision

MetadataPack

A runtime pack of type metadata used by variadic generic expansions.

public struct MetadataPack 

The Swift ABI uses the low bit of taggedPointer to distinguish heap-backed packs from packs borrowed from the stack. Only heap-backed packs can be enumerated: their element count is stored one word before the element pointer.

Initializers

init(taggedPointer:)

Creates a pack view for an ABI pointer from a generic argument layout.

public init(taggedPointer: UnsafeRawPointer) 

Properties

taggedPointer

The ABI pointer including its low-bit lifetime tag.

public let taggedPointer: UnsafeRawPointer

lifetime

Whether the elements are backed by the stack or a heap allocation.

public var lifetime: PackLifetime 

elementsPointer

The untagged address of the first metadata element.

public var elementsPointer: UnsafeRawPointer 

count

The number of elements when the runtime allocated the pack on the heap.

public var count: Int? 

Stack-backed packs do not carry their count and return nil.

elements

Metadata for every element of a heap-backed pack.

public var elements: [Metadata] 

Stack-backed packs return an empty array rather than reading a count from memory the ABI deliberately leaves unspecified.

Types
Protocols
Global Typealiases
Global Variables
Global Functions

Clone this wiki locally