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

Reply via email to