std::ostream
has an operator << (bool)
, and function names are implicitly convertible to bool
under the standard (by a function-to-pointer conversion followed by a boolean conversion). The relevant language is (§4 [conv]/p1, §4.3 [conv.func], §4.12 [conv.bool]) :
A standard conversion sequence is a sequence of standard conversions in the following order:
- Zero or one conversion from the following set: lvalue-to-rvalue conversion, array-to-pointer conversion, and function-to-pointer conversion.
- Zero or one conversion from the following set: integral promotions, floating point promotion, integral conversions, floating point conversions, floating-integral conversions, pointer conversions, pointer to member conversions, and boolean conversions.
- Zero or one qualification conversion.
An lvalue of function type T can be converted to a prvalue of type "pointer to T." The result is a pointer to the function.
A prvalue of arithmetic, unscoped enumeration, pointer, or pointer to member type can be converted to a prvalue of type
bool
. A zero value, null pointer value, or null member pointer value is converted tofalse
; any other value is converted totrue
.