- Title
- Promotion of enumeration with fixed underlying type
- Status
- c++14
- Section
- 7.3.7 [conv.prom]
- Submitter
- Ville Voutilainen
Created on 2013-01-09.00:00:00 last changed 143 months ago
Messages
Date: 2013-09-15.00:00:00
[Moved to DR at the September, 2013 meeting.]
Date: 2013-06-15.00:00:00
Proposed resolution (June, 2013): Change 12.2.4.3 [over.ics.rank] paragraph 4 as follows: ...Two conversion sequences with the same rank are indistinguishable unless
one of the following rules applies: A conversion that does not convert a pointer, a pointer to
member, or std::nullptr_t to bool is better than one that
does. A conversion that promotes an enumeration whose underlying type
is fixed to its underlying type is better than one that promotes to the
promoted underlying type, if the two are different. If class B is derived...
Date: 2013-01-09.00:00:00
According to 7.3.7 [conv.prom] paragraph 4, Because both of these conversions have the same rank, a call like
the following is ambiguous, even though conversion to the underlying
type might seem better than conversion to int : On the other hand, character types often have non-numeric
semantics in programs, and programmers might use a character type
just to set the size of the enumeration's object representation,
not to imply character semantics for the enumeration. It might be
better to leave the ambiguity in place in order to require
programmers to make their intent explicit.
A prvalue of an unscoped enumeration type whose underlying type is
fixed (9.8.1 [dcl.enum]) can be converted to a prvalue of its
underlying type. Moreover, if integral promotion can be applied to
its underlying type, a prvalue of an unscoped enumeration type whose
underlying type is fixed can also be converted to a prvalue of the
promoted underlying type.
enum E : char { e };
void f(char);
void f(int);
void g() {
f(e); // ambiguous
}
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2014-11-24 00:00:00 | admin | set | status: drwp -> c++14 |
| 2014-03-03 00:00:00 | admin | set | status: dr -> drwp |
| 2013-10-14 00:00:00 | admin | set | messages: + msg4681 |
| 2013-10-14 00:00:00 | admin | set | status: tentatively ready -> dr |
| 2013-09-03 00:00:00 | admin | set | messages: + msg4453 |
| 2013-09-03 00:00:00 | admin | set | status: drafting -> tentatively ready |
| 2013-05-03 00:00:00 | admin | set | status: open -> drafting |
| 2013-01-09 00:00:00 | admin | create | |