> On Jun 2, 2016, at 11:04 AM, Pyry Jahkola <[email protected]> wrote: > >> 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) {} > // ... > }
Brilliant! Why didn’t I think of that? :-) > > — Pyry >
_______________________________________________ swift-evolution mailing list [email protected] https://lists.swift.org/mailman/listinfo/swift-evolution
