更新时间:2023-02-14 22:21:32
这是完全有效和明智的标准C ++。
This is perfectly valid and sensible standard C++.
三元条件运算符形成一个 expression ,该表达式是一个
The ternary conditional operator forms an expression, and the expression is a constant expression if its operands are.
标准引用为C ++ 11 5.19 / 2:
The standard reference is C++11 5.19/2:
条件表达式是核心常量表达式 [...]
请注意,从5.16开始,三元条件表达式是 conditional-expressions 的一种。其他类型例如 2 == 3
。
Note that by 5.16, ternary conditional expressions are one type of conditional-expressions. Other types are things like 2 == 3
.