https://github.com/albin-johansson/safely
A C++ library that provides safe numeric APIs.
https://github.com/albin-johansson/safely
arithmetic cpp cpp17 library safety undefined-behavior
Last synced: 9 months ago
JSON representation
A C++ library that provides safe numeric APIs.
- Host: GitHub
- URL: https://github.com/albin-johansson/safely
- Owner: albin-johansson
- License: mit
- Created: 2025-08-05T23:20:03.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2025-09-21T13:32:51.000Z (9 months ago)
- Last Synced: 2025-09-21T15:16:05.523Z (9 months ago)
- Topics: arithmetic, cpp, cpp17, library, safety, undefined-behavior
- Language: C++
- Homepage:
- Size: 123 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Safely
[](https://github.com/albin-johansson/safely/actions/workflows/ci.yml)
Safely is a C++ library that provides safe numeric APIs, free of undefined behavior.
## Requirements
* C++17 or later
* Signed integers must use two's complement (verified at compile-time)
## Configuration
* Use `SAFELY_ENABLE_INTRINSICS` to control whether intrinsics such as `__builtin_add_overflow` are used
## See also
* SEI CERT C Coding Standard
* [Clang intrinsics](https://clang.llvm.org/docs/LanguageExtensions.html#checked-arithmetic-builtins)
* [GCC intrinsics](https://gcc.gnu.org/onlinedocs/gcc/Integer-Overflow-Builtins.html)
* [MSVC intrinsics](https://learn.microsoft.com/en-us/cpp/intrinsics/compiler-intrinsics)
* [boostorg/safe_numerics](https://github.com/boostorg/safe_numerics)