August 19, 2016
Code: https://github.com/dlang/phobos/pull/4613

Docs: http://dtest.thecybershadow.net/artifact/website-e0b2b4609f1a8e4010ccbe9492ab4af3e3fdd2fb-ab9e77dd6d78136b1f0172e60f7b4f43/web/phobos-prerelease/std_experimental_checkedint.html

New policies implement NaN and saturation with relative ease. I think it shouldn't be too hard to add bounds checks in a future iteration. Anyhow, reviews would be very welcome.


Andrei
August 23, 2016
On Friday, 19 August 2016 at 23:59:43 UTC, Andrei Alexandrescu wrote:
> Code: https://github.com/dlang/phobos/pull/4613
>
> Docs: http://dtest.thecybershadow.net/artifact/website-e0b2b4609f1a8e4010ccbe9492ab4af3e3fdd2fb-ab9e77dd6d78136b1f0172e60f7b4f43/web/phobos-prerelease/std_experimental_checkedint.html
>
> New policies implement NaN and saturation with relative ease. I think it shouldn't be too hard to add bounds checks in a future iteration. Anyhow, reviews would be very welcome.

BTW, there's something about which I've wondered before and which applies here, so maybe you could clarify... If you have something like std.algorithm.filter, you pass the filtering predicate function by a template alias, so there's no overhead introduced there (in the passing itself). But here the "hook" is not one function but a series of functions. For convenience you use a struct to aggregate those related functions, instead of passing them individually through a series of template aliases. My question is, how well do the compilers optimize away this 0-byte / 1-sizeof-byte, for this kind of use? Have there been situations where you had to use abstractions with worse ergonomics (e.g. template tuples, multiple template aliases, ...) to avoid the cost?