safeint

C++ class library for safe integer arithmetic with overflow detection

brewmacoslinux
Try with needOr install directly
Source

About

Class library for C++ that manages integer overflows

Commands

safeint

Examples

Include SafeInt header in C++ project to detect integer overflows$ #include <SafeInt.hpp> SafeInt<int> a = 2147483647; SafeInt<int> b = a + 1; // Throws exception on overflow
Use SafeInt for secure multiplication operations$ SafeInt<unsigned int> x = 100000; SafeInt<unsigned int> y = 100000; SafeInt<unsigned int> result = SafeMultiply(x, y);
Validate integer conversions between different types safely$ long long bigValue = 9223372036854775807LL; int smallValue; if (SafeCast(bigValue, smallValue)) { /* conversion safe */ }