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
std.conv: Fix ambiguity when target has ctor and source has opCast #1864
Conversation
{ | ||
struct T | ||
{ | ||
this(S s) @safe pure { } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Place an assert in here. We're supposed to call opCast, right?
I have just 1 question: There's an ambiguity between You chose to default to |
For assignment? I think this is something from C++.
I chose to prefer |
I'm thinking: S s;
T t = s; //Calls constructor For assignement, you need an explict cast or contruction anyways (unlike C++). T t;
t = s; //Fails
T = cast(T)s; //OK
T = T(s); //OK
Given that conv does "whatever it takes to build a T from an S", I think it would make more to do the same as the compiler. IMO. |
Right, I meant initialization, not assignment. Updated. |
LGTM. Anyone else? |
Auto-merge toggled on |
LG. |
std.conv: Fix ambiguity when target has ctor and source has opCast
For dlang/druntime#711