3 ms·
&+ isn't quite the same as + in C though. It's defined to perform wrapping overflow everytime, so more like integer + in Java. I don't think there's an addition
by gok 10y ago
&+ isn't quite the same as + in C though. It's defined to perform wrapping overflow everytime, so more like integer + in Java. I don't think there's an addition operator in Swift that means "not only don't do overflow checking, but also consider overflow impossible and optimize accordingly".
Not entirely clear that such an operator is ever what you really want, I suppose...
- mikeash 10y agoI believe you can get that behavior by using + in a file that you compile with -Ounchecked. I don't believe there's any built-in way to do it at an individual call site, short of writing a wrapper that you compile with -Ounchecked and then calling the wrapper where you want that behavior.
- gok 10y agoI think you're right, yeah.