...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
Safe Numerics |
This library started out as a re-implementation of the facilities provided by David LeBlanc's SafeInt Library. I found this library to be well done in every way. My main usage was to run unit tests for my embedded systems projects on my PC. Still, from my perspective it had a few issues.
It was a lot of code in one header - 6400 lines. Very unwieldy to understand, modify and maintain.
I couldn't find separate documentation other than that in the header file.
It didn't use Boost conventions for naming.
It required porting to different compilers.
It had a very long license associated with it.
I could find no test suite for the library.
Using later versions of C++ and the its standard library, template metaprogramming and Boost libraries I managed to (re)implement similar functionality in under 2000 ? lines of code. I promoted this version as a possible submission to the Boost. The feedback I received convinced me that no such library would be considered acceptable to the large majority of C++ programmers. It seems that the desire for maximum performance overrides any requirement that a program be known to be free of bugs. By this time I had a better idea of the opportunities available with the latest version of C++ (C++14) and resolved to address this issue by creating a library which would provide all the facilities of safe numerics at minimal runtime cost. The result is what you see here. The library now consists of 7000 lines of code, approximately 50 separate tests and more than 60 pages of documentation and examples.
Since I wrote the above, I've been contacted by David LeBlanc. He's been updating his package and informs me that the latest version:
SafeInt does not require porting for different compilers, is fully supported on gcc, clang, and Visual Studio.
The license has been changed from MS-PL to MIT license.
The library has had a test suite since before it was public, and is now located here:
SafeInt also has no external dependencies other than standard library files, and doesn't need anything else installed to work.
His current package can now be found at in github.