udaIndexOf

Returns the index of a given UDA, as annotated on a symbol.

enum udaIndexOf (
alias symbol
T
)

Parameters

symbol

Symbol to introspect.

T

UDA to get the index of.

Return Value

The index of the UDA if found, or -1 if it was not present.

Examples

enum UDA;
enum UDA2;

@UDA
@UDA2
@(42)
static void foo() {}

int i;

static assert(udaIndexOf!(foo, UDA) == 0);
static assert(udaIndexOf!(foo, UDA2) == 1);
static assert(udaIndexOf!(foo, int) == 2);
static assert(udaIndexOf!(foo, string) == -1);
static assert(udaIndexOf!(i, UDA) == -1);