Enum member protectionLevel

Check if the access level of any symbol

enum protectionLevel(symbol...) = cast(ProtectionLevel)__traits(getProtection, symbol[0]);

Example

import std.meta: AliasSeq;

static assert(protectionLevel!protectedImmutableInt == ProtectionLevel.protected_);

struct S {
    int i;
    public int m0;
    protected int m1;
    private int m2;
}

static assert(protectionLevel!(S.i) == ProtectionLevel.public_);
static assert(protectionLevel!(S.m0) == ProtectionLevel.public_);
static assert(protectionLevel!(S.m0) != ProtectionLevel.protected_);
static assert(protectionLevel!(S.m1) == ProtectionLevel.protected_);
static assert(protectionLevel!(S.m1) != ProtectionLevel.public_);
static assert(protectionLevel!(S.m2) == ProtectionLevel.private_);
static assert(protectionLevel!(S.m2) != ProtectionLevel.public_);