Created on 2007-12-22.00:00:00 last changed 196 months ago
[Voted into the WP at the September, 2008 meeting.]
Proposed resolution (June, 2008):
Add the following as a new paragraph following 7.6.1.9 [expr.static.cast] paragraph 8:
A value of a scoped enumeration type (9.7.1 [dcl.enum]) can be explicitly converted to an integral type. The value is unchanged if the original value can be represented by the specified type. Otherwise, the resulting value is unspecified.
There appears to be no provision in the Standard for explicit conversion of a value of a scoped enumeration type to an integral type, even though the inverse conversion is permitted. That is,
enum class E { e }; static_cast<E>(0); // #1: OK static_cast<int>(E::e); // #2: error
This is because values of scope enumeration types (intentionally) cannot be implicitly converted to integral types (7.3.7 [conv.prom] and 7.3.9 [conv.integral]) and 7.6.1.9 [expr.static.cast] was not updated to permit #2, although #1 is covered by paragraph 8.
History | |||
---|---|---|---|
Date | User | Action | Args |
2008-10-05 00:00:00 | admin | set | messages: + msg1810 |
2008-10-05 00:00:00 | admin | set | status: ready -> cd1 |
2008-06-29 00:00:00 | admin | set | messages: + msg1678 |
2008-06-29 00:00:00 | admin | set | status: drafting -> ready |
2008-03-17 00:00:00 | admin | set | status: open -> drafting |
2007-12-22 00:00:00 | admin | create |