Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

List initliazation of an enumeration with fixed underlying type from a single element v #4558

Closed
xmh0511 opened this issue Mar 26, 2021 · 2 comments

Comments

@xmh0511
Copy link
Contributor

xmh0511 commented Mar 26, 2021

Otherwise, if T is an enumeration with a fixed underlying type ([dcl.enum]) U, the initializer-list has a single element v, v can be implicitly converted to U, and the initialization is direct-list-initialization, the object is initialized with the value T(v)

v cannot be implicitly converted to U at all, since the following rule

An expression E can be implicitly converted to a type T if and only if the declaration T t=E; is well-formed, for some invented temporary variable t

enum A:int{
   a = 0
};
A a = 0; // ill-formed

There's no implicitly conversion that can convert 0 to type A. The relevant modification is suggested by CWG2374. However, its intent is:

v can be implicitly converted to the underlying type of T

So, Does it the current wording make no sense?

@xmh0511 xmh0511 changed the title List initliazation of an enumeration with fixed type from a single element v List initliazation of an enumeration with fixed underlying type from a single element v Mar 26, 2021
@xmh0511 xmh0511 closed this as completed Mar 26, 2021
@jwakely
Copy link
Member

jwakely commented Mar 26, 2021

U is the underlying type, int, not T.

@xmh0511
Copy link
Contributor Author

xmh0511 commented Mar 26, 2021

U is the underlying type, int, not T.

Sorry, I have recognized my misreading. So, I closed this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants