Skip to content

EnumValueWitnessTable

Azoy edited this page May 6, 2021 · 2 revisions

EnumValueWitnessTable

The value witness table for enums that have enum specific value witness functions.

public struct EnumValueWitnessTable: LayoutWrapper 

ABI Stability: Stable since the following

| macOS | iOS/tvOS | watchOS | Linux | Windows |
|-------|----------|---------|-------|---------|
| 10.14 | 12.2     | 5.2     | NA    | NA      |

Inheritance

LayoutWrapper

Properties

vwt

The base value witness table.

public var vwt: ValueWitnessTable 

Methods

getEnumTag(for:)

Given an instance of an enum, retrieve the "tag", the number that determines which case is currently being inhabited.

public func getEnumTag(for instance: UnsafeRawPointer) -> UInt32 

Parameters

  • instance: An enum instance of the type this value witness resides in.

Returns

The tag number for which case is being inhabited.

destructiveProjectEnumData(for:)

Given an instance of an enum, destructively remove the payload.

public func destructiveProjectEnumData(
    for instance: UnsafeMutableRawPointer
  ) 

Parameters

  • instance: An enum instance of the type this value witness resides in.

destructiveInjectEnumTag(for:tag:)

Given an instance of an enum and a case tag, destructively inject the tag into the enum instance.

public func destructiveInjectEnumTag(
    for instance: UnsafeMutableRawPointer,
    tag: UInt32
  ) 

Parameters

  • instance: An enum instance of the type this value witness resides in.
  • tag: A case tag value within [0..numCases)
Types
Protocols
Global Variables
Global Functions
Clone this wiki locally