Using __traits(getMember...) in alias statement

Tobias Pankrath tobias at pankrath.net
Thu Nov 17 09:12:15 PST 2011


It would be cool, if the following would be possible. 
----
immutable string MemberID = "M";

struct A {}
struct B {
    alias A M;
}

template Member(T)
{
    static if(__traits(hasMember, T, MemberID))
    {
        alias __traits(getMember, T, MemberID) Member;
    }
    else
        alias TypeTuple!() Member;
}

void main()
{
    alias Member!(B) M;
}
----

Currently dmd will print "basic type expected, not __traits".
Why isn't traits allowed here and if we allow __traits there, would this 
introduce any ambiguities?

Tobias


More information about the Digitalmars-d-learn mailing list