[swift-users] How to get UnsafePointer or UnsafeMutablePointer from ContiguousArray?
David Turnbull
dturnbull at gmail.com
Thu Feb 11 01:29:18 CST 2016
You want testarr2.withUnsafeMutableBufferPointer().
-david
On Wed, Feb 10, 2016 at 11:09 PM, Sergey Kuratov via swift-users <
swift-users at swift.org> wrote:
> Hello!
>
> I got some problem with ContiguousArray<->C interaction - I can't
> get address of array buffer to process in native code.
>
> Could somebody help me to get?
>
>
> Actually I also didn't find init(Array<...>) in UnsafePointer interface.
>
> I wonder what initialiser is used when UnsafePointer<T>(Array<T>)?
>
>
> Here is sample code:
>
>
> class Test {
>
> var a = 0
>
> }
>
>
> var testarr1 : Array<Test> = [ Test(), Test() ]
>
> var testarr2 : ContiguousArray<Test> = [ Test(), Test() ]
>
>
> let arrPtr1 = UnsafePointer<Test>(testarr1)
>
> let arrPtr2 = UnsafePointer<Test>(testarr2) <- error "Cannot invoke
> initialiser..."
>
>
>
> _______________________________________________
> swift-users mailing list
> swift-users at swift.org
> https://lists.swift.org/mailman/listinfo/swift-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20160210/b24d6a63/attachment.html>
More information about the swift-users
mailing list