Advanced Swift
Q92 / 100

What is Swift's memory layout and how does Unsafe APIs expose it?

Correct! Well done.

Incorrect.

The correct answer is B) MemoryLayout<T>.size/stride/alignment expose the exact byte layout. Unsafe APIs (UnsafePointer) allow direct memory manipulation matching C layouts

B

Correct Answer

MemoryLayout<T>.size/stride/alignment expose the exact byte layout. Unsafe APIs (UnsafePointer) allow direct memory manipulation matching C layouts

Explanation

MemoryLayout<Int>.size = 8 on 64-bit. MemoryLayout<(Int, Bool)>.stride = 16 (padding). Needed for C struct interop and performance analysis.

Progress
92/100