[Issue 6573] Add isOneOf to std.traits
    d-bugmail at puremagic.com 
    d-bugmail at puremagic.com
       
    Tue Aug 30 01:51:32 PDT 2011
    
    
  
http://d.puremagic.com/issues/show_bug.cgi?id=6573
bearophile_hugs at eml.cc changed:
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bearophile_hugs at eml.cc
--- Comment #2 from bearophile_hugs at eml.cc 2011-08-30 01:51:23 PDT ---
Something like this? (A different recursion base):
template SameTypes(X, T...) {
    static if (T.length)
        enum bool SameTypes = is(X == T[0]) && SameTypes!(X, T[1 .. $]);
    else
        enum bool SameTypes = true;
}
void main() {
    static assert (!SameTypes!(int, int, int, double));
    static assert (!SameTypes!(double, int, int, int));
    static assert (SameTypes!(double));
    static assert (SameTypes!(int));
    static assert (SameTypes!(int, typeof(1)));
    static assert (SameTypes!(int, typeof(1), typeof(2)));
}
-- 
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