Returns the distance from this pointer to the given pointer, counted as instances of the pointer’s
- Xcode 11.2+
- Swift Standard Library
The pointer to calculate the distance to.
The distance from this pointer to
end, in strides of the pointer’s
Pointee type. To access the stride, use
q, the result of
p is equivalent to
q - p.
Typed pointers are required to be properly aligned for their
Pointee type. Proper alignment ensures that the result of
distance(to:) accurately measures the distance between the two pointers, counted in strides of
Pointee. To find the distance in bytes between two pointers, convert them to
Unsafe instances before calling