STATIC_WARN
summary
When a static_assert would break portability but a compile time warning suffices this shows how to emit one by instantiating a templated warn_if type specialized to use a deprecated attribute and exposing it via a static_warn macro The macro evolves: add a defaulted constructor so it works in expressions then create an anonymous variable using token pasting with __COUNTER__ and __LINE__ so warnings point at the right site Works on GCC and MSVC Caveat do not replace static_assert
AI-written summary · about
related talks
42mHow to test static_assert?
10m'static_if' in C++14
01h 02mEmbedded Friendly C++: Features That Make a Difference
54mCompile-Time Validation in C++ Programming
52mHow to declare a constant in C++
05mLightning Talk: Detecting Constant Folding to Prevent Substitution Failure
01h 03mLifetime Safety in C++: Past, Present and Future
48mWhat is a static function but isn't a static function
