(Please no more macros, it's 202- I mean, 2023!)
static constexpr bool DEBUG = true; [[demo::invariant]] [[gnu::used]] void check_invariants() { if constexpr (!DEBUG) return; assert(top >= 0 && top <= MAX_SIZE); }
CMake defines the macro in release builds: https://github.com/Kitware/CMake/blob/e1eacbe2c522a8bf9a82af...
Would be nice to have a non-macro solution for controlling behavior at configure time, but the `NDEBUG` macro is basically already your `DEBUG` constexpr.
(Please no more macros, it's 202- I mean, 2023!)