The OpenD Programming Language

isProperty

Checks if member is property.

template isProperty (
T
string member
) {
static if(__traits(compiles, isSomeFunction!(__traits(getMember, *aggregate, member))))
static if(isSomeFunction!(__traits(getMember, *aggregate, member)))
enum bool isProperty;
static if(__traits(compiles, isSomeFunction!(__traits(getMember, *aggregate, member))))
static if(!(isSomeFunction!(__traits(getMember, *aggregate, member))))
enum bool isProperty;
static if(!(__traits(compiles, isSomeFunction!(__traits(getMember, *aggregate, member)))))
enum bool isProperty;
}

Examples

struct D
{
    int y;

    void gf(double ) @property {}
    void gf(uint ) @property {}
}

struct I
{
    int f;

    D base;
    alias base this;

    void gi(double ) @property {}
    void gi(uint ) @property {}
}

struct S
{
    int d;

    I i;
    alias i this;

    int gm() @property {return 0;}
    int gc() const @property {return 0;}
    void gs(int) @property {}
}

static assert(isProperty!(S, "gf"));
static assert(isProperty!(S, "gi"));
static assert(isProperty!(S, "gs"));
static assert(isProperty!(S, "gc"));
static assert(isProperty!(S, "gm"));
static assert(!isProperty!(S, "d"));
static assert(!isProperty!(S, "f"));
static assert(!isProperty!(S, "y"));

Meta