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



--- Comment #1 from Andrej Mitrovic <andrej.mitrov...@gmail.com> 2011-08-29 
20:16:51 PDT ---
However the code will have to be slightly improved.

If you accidentally pass a tuple followed by a single type things can get
weird.

E.g.:

template isOneOf(X, T...)
{
    static if (!T.length)
        enum bool isOneOf = false;
    else static if (is (X == T[0]))
        enum bool isOneOf = true;
    else
        enum bool isOneOf = isOneOf!(X, T[1..$]);
}

void test(T...)(T t)
{
    static assert (isOneOf!(T, double));  // passes by mistake
    static assert (isOneOf!(double, T));  // ok, fails properly

}

void main()
{
    test(1, 2, 3);
}

So that's something to improve.

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

Reply via email to