Why would this be an extension on UnsafePointer and not KeyPath?<br><div class="gmail_quote"><div dir="ltr">On Tue, Jun 6, 2017 at 10:28 Brent Royal-Gordon via swift-evolution <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">It won't happen for Swift 4, but I think we should eventually have APIs like:<br>
<br>
extension UnsafePointer {<br>
func advanced<T>(to keyPath: KeyPath<Pointee, T>) -> UnsafePointer<T>?<br>
}<br>
<br>
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.<br>
<br>
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.<br>
<br>
--<br>
Brent Royal-Gordon<br>
Sent from my iPhone<br>
_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
</blockquote></div>