for
loop:
for (int i = 0; i < 10; ++i) /* something */;The papers
if
, switch
, and range-based
for
statements.
Grammatically, this is an init-statement, which allows expressions and variable declarations as well as typedefs, but (inconsistently) not alias-declarations. This paper proposes to also allow alias-declarations.
C++20 | this paper |
---|---|
for (typedef int T; T e : v) /* something */; |
for (using T = int; T e : v) /* something */; |
The alternative would be to prohibit typedefs as an init-statement, but while unusual, they seem useful in some situations. After all, the argument of a reduced scope for variables introduced in an init-statement applies to typedefs as well.
#error
check seems weak, since the compiler error
message for an unrecognized alias-declaration is unconditional
and should be clear.
This has not been implemented.
init-statement: expression-statement simple-declaration alias-declaration