Enum member isRefDecl

True if it's a ref decleration. This applies to parameters and functions

enum isRefDecl(T...) = [__traits(getFunctionAttributes, T[0])].canFind("ref");


bool checkRefParam()(auto ref int i) {
    return isRefDecl!i;

bool checkRefReturn() {
    ref int f(ref int i) {
        return i;
    return isRefDecl!f;

bool checkMemberFunciton() {
    static struct S {
        int i;
        ref int value() return { return i; }
    S s;
    return isRefDecl!(s.value) && isRefDecl!(S.value);

int i;
assert(        checkRefParam(i));
static assert(!checkRefParam(3));
static assert( checkRefReturn());
static assert( checkMemberFunciton());
static assert(!isRefDecl!int);
static assert(!isRefDecl!i);