[swift-users] How to get UnsafePointer or UnsafeMutablePointer from ContiguousArray?

Dmitri Gribenko gribozavr at gmail.com
Thu Feb 11 01:54:17 CST 2016

Re-adding swift-users back.

On Wed, Feb 10, 2016 at 11:49 PM, Sergey Kuratov <ksubox.swift at gmail.com> wrote:
> Thank you, Dmitri!
> I wonder how this automatic transformation to unsafe pointer happens (I
> guess elements buffer has some offset from array object memory) ?

The compiler knows how to extract the pointer from the array, and how
to extend its lifetime to ensure it is not deallocated before the C
function returns.

> Can I define similar for my Swift classes ?

No.  What would be your usecase?


(j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr at gmail.com>*/

More information about the swift-users mailing list