isSafe

true if func is @safe or @trusted.

template isSafe (
alias func
) if (
isCallable!func
) {
enum isSafe;
}

Examples

@safe    int add(int a, int b) {return a+b;}
@trusted int sub(int a, int b) {return a-b;}
@system  int mul(int a, int b) {return a*b;}

static assert( isSafe!add);
static assert( isSafe!sub);
static assert(!isSafe!mul);

Meta