The memory layout of a type, describing its size, stride, and alignment.
SDK
Xcode 8.0+
Framework
Swift Standard Library
Declaration
Overview
You can use MemoryLayout as a source of information about a type when allocating or binding memory using raw pointers. The following example declares a Point type with x and y coordinates and a Boolean isFilled property.
The size, stride, and alignment of the Point type are accessible as static properties of MemoryLayout<Point>.
Always use a multiple of a type’s stride instead of its size when allocating memory or accounting for the distance between instances in memory. This example allocates uninitialized raw memory with space for four instances of Point.
Topics
Accessing the Layout of a Type
Use these static properties to access a type's layout. For example, the size of a Double instance is MemoryLayout<Double>.size.