digitalmars.D.bugs - [Issue 10006] New: Implicit conversion in initializers doesn't work for subtypes
- d-bugmail puremagic.com (29/29) Apr 29 2013 http://d.puremagic.com/issues/show_bug.cgi?id=10006
- d-bugmail puremagic.com (15/15) Apr 29 2013 http://d.puremagic.com/issues/show_bug.cgi?id=10006
http://d.puremagic.com/issues/show_bug.cgi?id=10006 Summary: Implicit conversion in initializers doesn't work for subtypes Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: andrej.mitrovich gmail.com 03:30:47 PDT --- ----- 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. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Apr 29 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10006 03:32:28 PDT --- This does give me an idea for a DIP: struct S { float value = 0.0; alias value this; // called only when a *literal* is provided this(enum double val) { } } This would enable creating custom implicit conversions when initializing a struct with a literal of some sort. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Apr 29 2013