> On Jul 18, 2016, at 11:44 AM, Karl via swift-users
> wrote:
>
> Also, as interesting as that may be, I’m also curious what to do in the
> general case for types without magic compiler optimisations.
Wait for Swift 4, apparently:
https://github.com/apple/swift-evolution/blob/master/proposals
> On 18 Jul 2016, at 14:51, Martin R wrote:
>
> This is not an answer to your question, but note that you can pass a Swift
> String to functions expecting an UnsafePointer (C String) parameter,
> and the compiler will generate a temporary NUL-terminated UTF-8
> representation for you:
>
> l
This is not an answer to your question, but note that you can pass a Swift
String to functions expecting an UnsafePointer (C String) parameter, and
the compiler will generate a temporary NUL-terminated UTF-8 representation for
you:
let io = DispatchIO(type: .stream, path: "/path/to/file", ...
As I understand it, we are supposed to use withUnsafe{Mutable/Buffer}Pointer or
withExtendedLifetime to guarantee that objects we take pointers of will exist
and won’t be optimised out by the compiler.
However, this leads to a problem when trying to initialise something which
expects a UTF8 str