This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 113d. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2024-03-20


1320. Converting scoped enumerations to bool

Section: 7.6.1.9  [expr.static.cast]     Status: CD3     Submitter: Jonathan Wakely     Date: 2011-05-18

[Moved to DR at the April, 2013 meeting.]

The specification of static_cast (7.6.1.9 [expr.static.cast]) does not describe conversion of a scoped enumeration value to bool. Presumably it should be handled as for unscoped enumerations, with a zero value becoming false and a non-zero value becoming true.

Proposed resolution (August, 2012):

Change 7.6.1.9 [expr.static.cast] paragraph 9 as follows:

A value of a scoped enumeration type (9.7.1 [dcl.enum]) can be explicitly converted to an integral type. The When that type is cv bool, the resulting value is false if the original value is zero and true for all other values. For the remaining integral types, the value is unchanged if the original value can be represented by the specified type. Otherwise, the resulting value is unspecified.