isFunction

Detect whether symbol or type X is a function. This is different that finding if a symbol is callable or satisfying is(X == function), it finds specifically if the symbol represents a normal function declaration, i.e. not a delegate or a function pointer.

template isFunction () {
static if(is(typeof(&X) U : U*) && is(U == function) || is(typeof(&X) U == delegate))
enum isFunction;
static if(!(is(typeof(&X) U : U*) && is(U == function) || is(typeof(&X) U == delegate)))
static if(is(X T))
enum isFunction;
static if(!(is(typeof(&X) U : U*) && is(U == function) || is(typeof(&X) U == delegate)))
static if(!(is(X T)))
enum isFunction;
}

Return Value

true if X is a function, false otherwise

Examples

static void func(){}
static assert(isFunction!func);

struct S
{
    void func(){}
}
static assert(isFunction!(S.func));

See Also

Use isFunctionPointer or isDelegate for detecting those types respectively.

Meta