2 ms·
I would use std::enable_if or C++20 concepts. Both work fine for selectively enabling functions.
by jjmarr 1y ago
I would use std::enable_if or C++20 concepts. Both work fine for selectively enabling functions.
- quotemstr 1y agoYes, but not for accommodating missing definitions or platform specific syntax. A true static if MUST allow invalid syntax in branches not taken if it's to fully replace the preprocessor.
- sfpotter 1y agoC++20 concepts are a step in the right direction, but: - D had this feature long before C++ did. - It isn't the same thing as "static if". Without "static if", conditionally compiling variables into classes is much more elaborate, basically requiring subclassing to do, which is not really semantically how subclassing should be used (the result is also way more confusing and oblique than the equivalent directly expressed construct you'd have using "static if").