getMemberUDAs

* Params: * member = symbol of a member * UDA = User defined attribute of the member * Returns: *

template getMemberUDAs (
alias member
alias UDA
) {}

Examples

import std.typecons : Tuple;

enum test;
struct special {
    string label;
}

struct S {
    @test
    int func() {
        return 0;
    }

    @special("text")
    int func(int x) {
        return x;
    }

    string func(string str) {
        return str;
    }
}

static assert(getName!(S.func) == "func");
static assert(__traits(isSame, __traits(getOverloads, S, "func"), getOverloads!(S.func)));
/// UDA @test
static assert(hasMemberUDA!(S.func, test).length is 1);
static assert(__traits(isSame, hasMemberUDA!(S.func, test)[0], getOverloads!(S.func)[0]));
static assert(is(getMemberUDAs!(S.func, test)[0] == test));
/// UDA special
static assert(hasMemberUDA!(S.func, special).length is 1);
static assert(__traits(isSame, hasMemberUDA!(S.func, special)[0], getOverloads!(S.func)[1]));
enum s_special = getMemberUDAs!(S.func, special)[0];
static assert(s_special == special("text"));