[Issue 8143] Safe std.conv.to enum conversion

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Oct 24 08:02:38 PDT 2012


http://d.puremagic.com/issues/show_bug.cgi?id=8143



--- Comment #4 from Andrej Mitrovic <andrej.mitrovich at gmail.com> 2012-10-24 08:02:31 PDT ---
Or alternatively require an additional alias parameter for the comparison
function in case of floats?

E.g.

    enum EF : float { C = 4.9 }
    float f = 4.9;
    static bool compFunc(float lhs, float rhs) { ... }
    EF en2 = to!(EF, compFunc)(f);

Since conv.to will already do the work necessary to 1) find the matching
member, 2) ensure there's only 1 matching member, I think customization like
this might be friendlier than just rejecting conversion.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list