How to implement filterMap

Siarhei Siamashka siarhei.siamashka at gmail.com
Sun Jan 28 06:20:14 UTC 2024


On Sunday, 31 December 2023 at 14:47:27 UTC, Alexandru Ermicioi 
wrote:
> `CheckedInt` should be another solution for overflows, if you 
> really need it to throw exceptions, on overflow errors.

CheckedInt is worse than nothing. It exists to give an illusion 
of having at least something to address this problem in D 
language, but it only acts as a distraction and drains valuable 
time. I don't see any practical scenario, where it would be 
useful. My current solution is to use a custom build of GDC with 
`-ftrapv` option for arithmetic overflows diagnostics. It's far 
from perfect, but at least it does the job in a non-invasive way 
without having any need to patch my code.


More information about the Digitalmars-d-learn mailing list