Title
Converting scoped enumerations to bool
Status
cd3
Section
7.6.1.9 [expr.static.cast]
Submitter
Jonathan Wakely

Created on 2011-05-18.00:00:00 last changed 131 months ago

Messages

Date: 2013-04-15.00:00:00

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

Date: 2012-08-15.00:00:00

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.
Date: 2012-09-24.00:00:00

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.

History
Date User Action Args
2014-03-03 00:00:00adminsetstatus: drwp -> cd3
2013-10-14 00:00:00adminsetstatus: dr -> drwp
2013-05-03 00:00:00adminsetmessages: + msg4383
2013-05-03 00:00:00adminsetstatus: ready -> dr
2012-11-03 00:00:00adminsetstatus: tentatively ready -> ready
2012-09-24 00:00:00adminsetmessages: + msg3877
2012-09-24 00:00:00adminsetstatus: drafting -> tentatively ready
2011-05-18 00:00:00admincreate