[Issue 9828] Inconsistent lowering of 1-element tuple to its element

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Mar 29 08:59:31 PDT 2013


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



--- Comment #1 from Andrej Mitrovic <andrej.mitrovich at gmail.com> 2013-03-29 08:59:30 PDT ---
Here's an example of why it would be useful if it's consistently allowed:

import std.typetuple;

template getTypes(T...)
{
    alias getTypes = T;
}

void test(T)(T t)
{
    alias attributes = getTypes!(__traits(getAttributes, T));

    // NG: Even if tuple length is 1
    // static if (attributes == "S1") { }

    // NG: '(string)' and '(string)' (why are they not comparable?)
    // static if (attributes == TypeTuple!("S1")) { }

    // Note: .length check is necessary, otherwise out of bounds errors occur
    static if (attributes.length && attributes[0] == "S1")
    {
        pragma(msg, T);
    }
}

void main()
{
    @("S1") static struct S1 { }
    static struct S2 { }
    test(S1());
    test(S2());
}

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