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

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Oct 26 16:40:24 PDT 2012


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



--- Comment #20 from Andrej Mitrovic <andrej.mitrovich at gmail.com> 2012-10-26 16:40:22 PDT ---
(In reply to comment #16)
> Another significant test case, this is useful in many simulations and games, to
> write safe tables and start conditions:
> 
> enum Code : char { A='A', B='B', C='C' }
> 
> void test()
> {
> ...
>     const code = to!(Code[][])(["ABCCBA", "BBAA"]);
>     with (Code)
>         assert(code == [[A, B, C, C, B, A], [B, B, A, A]]);
> }

I won't be able to do this, the problem is there is already a toImpl overload
which takes a string and turns it into an enum. It has different semantics, it
searches for matching member names rather than member values.

-- 
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