The SaferC++ library provides safer implementations for many native C++ types. The library provides features such as:
- Data types that are designed for multi-threaded use and asynchronous access
- Drop-in replacements for
std::vector,std::array,std::string,std::string_viewthat provide improved memory safety - Drop-in replacements for
int,size_t, andboolthat protect against use of uninitialized values and sign-unsigned comparison issues (similar totype_safe) - Improved pointer & reference types with different compatibility and performance tradeoffs
SaferC++ is usable with embedded systems as long as your platform has a functional STL implementation. Exception behavior can be controlled for your platform by modifying the MSE_CUSTOM_THROW_DEFINITION macro.
Using the library does incur a performance penalty. However, SaferC++ elements can be disabled during compile time (i.e. replaced with the standard type equivalents). This allows users to enable debug and test builds to use safer-but-slower features without adding overhead to release builds.
Since the SaferC++ types provide added safety and can be disabled when performance matters, I highly recommend using their drop-in types to catch and eliminate possible errors when using STL types. The easiest way to get started with SaferC++ is to utilize the mse::vector and mse::array types in place of std::vector and std::array. These types will help you catch potential memory issues lurking in your software. The README provides further tips for making your code safer.
Further Reading
For more on SaferC++:
