[Issue 9924] Handy enum accessors
    d-bugmail at puremagic.com 
    d-bugmail at puremagic.com
       
    Thu Apr 11 18:51:21 PDT 2013
    
    
  
http://d.puremagic.com/issues/show_bug.cgi?id=9924
--- Comment #3 from bearophile_hugs at eml.cc 2013-04-11 18:51:20 PDT ---
If you remove FirstMember and LastMember the whatBeats() function:
    static Choice whatBeats(in Choice ch) /*pure nothrow*/ {
        if (ch == LastMember!Choice)
            return FirstMember!Choice;
        else
            return nextMember(ch);
    }
Becomes:
    static Choice whatBeats(in Choice ch) /*pure nothrow*/ {
        if (ch == EnumMembers!Choice[$ - 1])
            return EnumMembers!Choice[0];
        else
            return nextMember(ch);
    }
It's more noisy, and visually it's a little less easy to tell it's correct.
-- 
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