Skip to content

withProjectedValue(of___)

tevelee edited this page Jul 27, 2026 · 1 revision

withProjectedValue(of:_:)

Projects an erased value's dynamic type and initialized storage for the duration of body.

public func withProjectedValue<Result>(
  of instance: Any,
  _ body: (Any.Type, UnsafeRawPointer) throws -> Result
) rethrows -> Result 

The projected pointer is valid only while body executes. This provides a scoped way to perform an operation selected by the value's dynamic type; it does not materialize the value for a different existential or ABI representation.

Parameters

  • instance: An erased Swift value to project.
  • body: Receives the value's dynamic type and initialized storage.

Returns

The result of body.

Types
Protocols
Global Typealiases
Global Variables
Global Functions

Clone this wiki locally