[Issue 10258] Add hasAccess trait

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Jul 19 11:11:15 PDT 2013


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



--- Comment #5 from Kenji Hara <k.hara.pg at gmail.com> 2013-07-19 11:11:13 PDT ---
I think hasAccess traits would be completely redundant feature.

We can use __traits(compiles) + __traits(getMember).

module a;
struct S { int x;  private int y; }

module b;
import a;
void getValues(T)(T t)
{
    import std.stdio;
    foreach (name; __traits(allMembers, T))
    {
        static if (__traits(compiles, __traits(getMember, t, name)))
            writeln(name, ": ", mixin("t."~name));
    }
}
void main()
{
    S s;
    getValues(s);
}

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