On Jun 28, 2016, at 12:11 PM, Dave Abrahams via swift-evolution <swift-evolution@swift.org> wrote: >>> I think it would. It would *really* help if someone would prepare a >>> patch that uses both APIs so we could see how the resulting code looks >>> in practice. :-) >>> >>> -- >>> Dave >> >> Here you go: >> https://gist.github.com/erica/57a64163870486468180b8bab8a6294e >> <https://gist.github.com/erica/57a64163870486468180b8bab8a6294e >> <https://gist.github.com/erica/57a64163870486468180b8bab8a6294e>> > > Thanks for the proposal, Erica. It contains some errors that I pointed > out in a comment on the Gist. Care to fix those? >
public struct MemoryLayout<T> { public static var size: Int { return sizeof(T) } public static var interval: Int { return strideof(T) } public static var alignment: Int { return alignof(T) } init(_ : @autoclosure () -> T) {} } print(MemoryLayout<Int>.size) // 8 print(MemoryLayout<Int>.interval) // 8 print(MemoryLayout<Int>.alignment) // 8 let x = 8 print(MemoryLayout(x).dynamicType.size) // 8 print(MemoryLayout(x).dynamicType.interval) // 8 print(MemoryLayout(x).dynamicType.alignment) // 8 -- E
_______________________________________________ swift-evolution mailing list swift-evolution@swift.org https://lists.swift.org/mailman/listinfo/swift-evolution