A C++20 library that replaces preprocessor macros with constexpr detection of compilers, architectures, SIMD extensions, and operating systems.
SPY is a C++20 library that acts as an information broker for the compilation environment. It detects and versions compilers, architectures, SIMD extensions, and operating systems at compile-time, replacing traditional preprocessor macros with a clean, constexpr interface. This solves the problem of messy, hard-to-maintain `#ifdef` spaghetti in cross-platform C++ code.
C++ developers building cross-platform applications, libraries, or performance-critical code that needs to adapt to different compilers, architectures, or SIMD capabilities. It's particularly useful for those targeting multiple operating systems or hardware platforms.
Developers choose SPY because it provides a modern, type-safe, and constexpr-compatible way to handle environment detection, eliminating error-prone preprocessor macros. Its hierarchical SIMD detection and comprehensive compiler/architecture support make it a robust, header-only solution with zero dependencies.
SPY - C++ Information Broker
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Supports detection of multiple compilers, architectures, SIMD extensions, and OS as listed in the README tables, providing a one-stop solution that replaces scattered macro checks.
Replaces error-prone #ifdef spaghetti with compile-time boolean checks and version queries, making code more readable and maintainable, as demonstrated in the Quick Start example.
Has no dependencies and offers easy integration via CMake FetchContent or as a single header from the standalone branch, simplifying project setup without external overhead.
Enables intuitive comparisons like 'spy::simd_instruction_set >= spy::avx2_' for checking feature levels, which is more straightforward than individual macro checks for each SIMD extension.
Mandates C++20 due to its heavy reliance on constexpr features, limiting adoption in legacy projects or environments that cannot upgrade to modern standards.
Detection is static and cannot adapt to runtime changes, such as CPU hot-swapping or fallback mechanisms, making it unsuitable for dynamic systems or progressive enhancement.
As a header-only library with extensive constexpr usage, it might increase compile times or binary size in large projects, though this is a common trade-off for template-heavy code.