Why would this be an extension on UnsafePointer and not KeyPath? On Tue, Jun 6, 2017 at 10:28 Brent Royal-Gordon via swift-evolution < swift-evolution@swift.org> wrote:
> It won't happen for Swift 4, but I think we should eventually have APIs > like: > > extension UnsafePointer { > func advanced<T>(to keyPath: KeyPath<Pointee, T>) -> UnsafePointer<T>? > } > > If keyPath referred to a stored property directly inside the value, this > would return a pointer to that property. If keyPath is a computed property, > or the property is not stored relative to the pointer (e.g. an object or > indirect pointer), it returns nil. > > My most immediate use case is for working with MIDI structures, which have > an inline byte buffer, but I suspect there will be other uses as well. > > -- > Brent Royal-Gordon > Sent from my iPhone > _______________________________________________ > swift-evolution mailing list > swift-evolution@swift.org > https://lists.swift.org/mailman/listinfo/swift-evolution >
_______________________________________________ swift-evolution mailing list swift-evolution@swift.org https://lists.swift.org/mailman/listinfo/swift-evolution