safeint

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

brewmacoslinux
Try with needOr install directly
Source

About

Class library for C++ that manages integer overflows

Examples

check if adding two numbers will overflow$ g++ -I$(brew --prefix safeint)/include example.cpp -o example && ./example
prevent integer overflow in multiplication operations$ #include <SafeInt.hpp> int main() { SafeInt<int> a = 100000; SafeInt<int> b = 100000; auto result = a * b; }
validate user input won't cause integer wraparound$ #include <SafeInt.hpp> SafeInt<unsigned int> value = user_input; // throws on overflow
safely convert between different integer types$ #include <SafeInt.hpp> SafeInt<int> small = SafeInt<long long>(large_value);
compile C++ code using safe integer library headers$ g++ -I$(brew --prefix safeint)/include -std=c++11 myprogram.cpp -o myprogram