You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-----
struct S
{
float value = 0.0;
alias value this;
}
float f = 250.0; // ok
S s = 250.0; // ng
void main() { }
-----
Error: cannot implicitly convert expression (250.000) of type double to S
I think the above should work.
The text was updated successfully, but these errors were encountered:
andrej.mitrovich (@AndrejMitrovic) commented on 2013-04-29T03:32:28Z
This does give me an idea for a DIP:
struct S
{
float value = 0.0;
alias value this;
// called only when a *literal* is providedthis(enum double val) { }
}
This would enable creating custom implicit conversions when initializing a struct with a literal of some sort.
Andrej Mitrovic (@AndrejMitrovic) reported this on 2013-04-29T03:30:47Z
Transferred from https://issues.dlang.org/show_bug.cgi?id=10006
Description
The text was updated successfully, but these errors were encountered: