isCallable

Detect whether T is a callable object, which can be called with the function call operator $(LPAREN)...$(RPAREN).

template isCallable (
T...
) if (
T.length == 1
) {
enum bool isCallable;
enum bool isCallable;
enum bool isCallable;
}

Examples

interface I { real value() @property; }
struct S { static int opCall(int) { return 0; } }
class C { int opCall(int) { return 0; } }
auto c = new C;

static assert( isCallable!c);
static assert( isCallable!S);
static assert( isCallable!(c.opCall));
static assert( isCallable!(I.value));
static assert( isCallable!((int a) { return a; }));

static assert(!isCallable!I);

Meta

Suggestion Box / Bug Report