3 ms·
Opinions differ I guess. I would love it if if constexpr ( COND) { CODE }; would compile even if CODE only compiles when COND is true. There a lot of nice
by toth 10y ago
Opinions differ I guess. I would love it if
if constexpr ( COND) { CODE };
would compile even if CODE only compiles when COND is true. There a lot of nice use cases for that, and that's how the static_if in D works.
You can still do this sort of stuff with template overloads, but it's much more cumbersome.
- Kristine1975 10y agoThat's the case though, as long as CODE is syntactically correct. So this would compile: if constexpr (condition) { print("yes"); } While this wouldn't: if constexpr (condition) { print({ } At least that's my understanding.