> The comments in the generated header for UnsafeMutablePointer claim that
its regular init() method constructs a null pointer.

That's right, and I have tried it as well. Yet, type inference doesn't like
like it, and I get back an error similar to what I have already described,
but this time with inout and UnsafeMutablePointer:

    result values in '? :' expression have mismatching types 'inout T' and
'UnsafeMutablePointer<T>'


On Thu, Dec 24, 2015 at 7:56 AM, Charles Srstka <[email protected]>
wrote:

> On Dec 23, 2015, at 7:50 PM, Félix Cloutier via swift-evolution <
> [email protected]> wrote:
>
>
> The & operator isn't exactly an address-of operator. Does &arr[0] even
> return a pointer to the inner buffer? When you use & with properties (and
> possibly with subscripts as well), Swift may create a local, copy the
> property value to it, pass a pointer to that local, and copy back the
> output to the property.
>
> Anyway, you are probably looking for
> Array.withUnsafe(Mutable?)BufferPointer:
>
> arr.withUnsafeMutableBufferPointer { foo($0, $0.count) }
>
> Félix
>
>
> The comments in the generated header for UnsafeMutablePointer claim that
> its regular init() method constructs a null pointer. Therefore, I think you
> should just be able to:
>
> foo(UnsafeMutablePointer<T>(), 0)
>
> Charles
>
>


-- 
Author of the Sparkling language
http://h2co3.org/
_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to