What prevents compilers from compiling a static_assert
placed in for-init-statement of the for statement?
For example:
for(static_assert(true, ""); false; ); // error
Grammatically. A for
loop is:
for ( init-statement; conditionopt ; expressionopt ) statement
where an init-statement is either an expression followed by a ;
or a simple-declaration. A static_assert-declaration is neither of those things, hence it can't go there.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With