Protection attribute in another module

jmh530 via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Aug 30 14:47:13 PDT 2017


On Wednesday, 30 August 2017 at 21:15:56 UTC, Kagamin wrote:
> Something like mixin("__traits(getProtection, A."~member~")")

The following compiles without error. It would be nice if 
something like this got added to std.traits.

template getProtection(string from, string member)
{
     mixin("static import " ~ from ~ ";");
     enum string getProtection =
                   mixin("__traits(getProtection, " ~ from ~ "." ~ 
member ~ ")");
}

@safe unittest
{
     assert(getProtection!("std.algorithm", "map") == "public");
}


More information about the Digitalmars-d-learn mailing list