Difference between revisions of "Template:cpp/language/condition"
From cppreference.com
m (→Condition: as if...) |
m (→Condition: fix again...) |
||
Line 4: | Line 4: | ||
* If it can be syntactically resolved as a {{rlp|structured binding}} declaration, it is interpreted as a structured binding declaration. | * If it can be syntactically resolved as a {{rlp|structured binding}} declaration, it is interpreted as a structured binding declaration. | ||
}} | }} | ||
− | * If it can be syntactically resolved as an expression, it is treated as an expression. Otherwise, it is treated as | + | * If it can be syntactically resolved as an expression, it is treated as an expression. Otherwise, it is treated as a declaration{{rev inl|since=c++26| that is not a structured binding declaration}}. |
When control reaches condition, the condition will yield a value, which is used to {{{usage|}}}. | When control reaches condition, the condition will yield a value, which is used to {{{usage|}}}. |
Latest revision as of 17:03, 1 November 2024
Contents |
[edit] Condition
A condition can either be an expression or a simple declaration.
|
(since C++26) |
- If it can be syntactically resolved as an expression, it is treated as an expression. Otherwise, it is treated as a declaration that is not a structured binding declaration(since C++26).
When control reaches condition, the condition will yield a value, which is used to .
[edit] Expression
If condition is an expression, the value it yields is the the value of the expression.
[edit] Declaration
If condition is a simple declaration, the value it yields is the value of the decision variable (see below).
[edit] Non-structured binding declaration
The declaration has the following restrictions:
- Syntactically conforms to the following form:
|
(until C++11) |
|
(since C++11) |
- The declarator cannot specify a function or an array.
- The type specifier sequence(until C++11)declaration specifier sequence can only contain type specifiers and constexpr, and it(since C++11) cannot define a class or enumeration.
The decision varaiable of the declaration is the declared variable.
Structured binding declarationThe declaration has the following restrictions:
The decision variable of the declaration is the invented variable e introduced by the declaration. |
(since C++26) |