[swift-evolution] [Pitch] Renaming sizeof, sizeofValue, strideof, strideofValue

Pyry Jahkola pyry.jahkola at iki.fi
Thu Jun 2 11:04:16 CDT 2016


> Matthew Johnson wrote:
> 
> Going with MemoryLayout *does not* mean we would have to give up the value functions if we don’t want to:
> 
> struct MemoryLayout<T> {
>     init(t: T) { /* throw away the value */ }
>     // …
> }
> 
> let sizeOfValue = MemoryLayout(42).size

You could also use @autoclosure here to avoid evaluating whatever expression there is:

struct MemoryLayout<T> {
    init(_: @autoclosure () -> T) {}
    // ...
}

— Pyry

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160602/0aeea3d6/attachment.html>


More information about the swift-evolution mailing list