Enum member isUnaryOver

Returns true if the first argument is a unary function over the next parameter argument

enum isUnaryOver(T...) = T.length == 2 && (isFunctionOver!T || is(typeof(unaryFun!(T[0])(T[1].init))));

Parameter arguments can be any compile time entity that can be typed. And the first argument can be a string that is also accpeted by std.functional.binaryFun in Phobos


void f0() {}
void f1(int a) {}
void f2(int a, int b) {}

static assert(!isUnaryOver!(null, int));
static assert( isUnaryOver!((a => a), int));
static assert(!isUnaryOver!((a, b) => a + b, int));

static assert(!isUnaryOver!(f0, int));
static assert( isUnaryOver!(f1, int));
static assert(!isUnaryOver!(f2, int));

static assert( isUnaryOver!(f1, 3));
static assert(!isUnaryOver!(f1, "ff"));
static assert(!isUnaryOver!(f1, 3, 4));
static assert( isUnaryOver!(typeof(f1), 3));
static assert(!isUnaryOver!(typeof(f1), "ff"));