A boolean-expression is an expression that yields a result of type bool; either directly or through application of operator true in certain contexts as specified in the following.
boolean-expression:
expression
The controlling conditional expression of an if-statement (§8.7.1), while-statement (§8.8.1), do-statement (§8.8.2), or for-statement (§8.8.3) is a boolean-expression. The controlling conditional expression of the ?: operator (§7.14) follows the same rules as a boolean-expression, but for reasons of operator precedence is classified as a conditional-or-expression.
A boolean-expression E is required to be able to produce a value of type bool, as follows:
If E is implicitly convertible to bool then at runtime that implicit conversion is applied.
Otherwise, unary operator overload resolution (§7.3.3) is used to find a unique best implementation of operator true on E, and that implementation is applied at runtime.
If no such operator is found, a binding-time error occurs.
The DBBool struct type in §11.4.2 provides an example of a type that implements operator true and operator false.
Do'stlaringiz bilan baham: |