The first argument is the function to check, the second are the types it should be called over
1 int i; 2 float f; 3 void f0() {} 4 void f1(int a) {} 5 void f2(int a, string b) {} 6 void f3(int a, string b, float c) {} 7 8 static assert( isFunctionOver!(f0)); 9 static assert(!isFunctionOver!(f0, int)); 10 11 static assert(!isFunctionOver!(f1, string)); 12 static assert( isFunctionOver!(f1, int)); 13 static assert( isFunctionOver!(f1, i)); 14 static assert(!isFunctionOver!(f1, f)); 15 16 static assert(!isFunctionOver!(f2, int)); 17 static assert( isFunctionOver!(f2, int, string)); 18 static assert(!isFunctionOver!(f2, int, float)); 19 static assert(!isFunctionOver!(f2, int, float, string)); 20 21 static assert( isFunctionOver!(f3, int, string, float)); 22 static assert(!isFunctionOver!(f3, int, float, string)); 23 static assert(!isFunctionOver!(f3, int, float)); 24 static assert(!isFunctionOver!(f3, int)); 25 static assert(!isFunctionOver!(f3)); 26 27 static assert( isFunctionOver!(() => 3)); 28 static assert(!isFunctionOver!(() => 3, int)); 29 static assert(!isFunctionOver!(a => a, float, int)); 30 static assert( isFunctionOver!(a => a, float)); 31 static assert( isFunctionOver!(a => a, int)); 32 static assert( isFunctionOver!((int a) => a, short)); 33 static assert(!isFunctionOver!((int a) => a, float)); 34 static assert(!isFunctionOver!(a => a)); 35 static assert( isFunctionOver!((a, b) => a + b, float, int)); 36 37 struct A {} 38 static assert(!isFunctionOver!((a, b) => a + b, A, int)); 39 static assert( isFunctionOver!((a, b, c, d) => a+b+c+d, int, int, int ,int)); 40 41 import std.functional: unaryFun; 42 static assert( isFunctionOver!(unaryFun!"a", int)); 43 static assert(!isFunctionOver!(unaryFun!"a", int, int)); 44 45 import std.functional: binaryFun; 46 static assert(!isFunctionOver!(binaryFun!"a", int)); 47 static assert( isFunctionOver!(binaryFun!"a", int, int)); 48 static assert( isFunctionOver!(binaryFun!"a > b", int, int)); 49 static assert(!isFunctionOver!(binaryFun!"a > b", int, int, int)); 50 51 class C {} 52 class D : C {} 53 void fc(C) {} 54 void fd(D) {} 55 static assert( isFunctionOver!(fc, C)); 56 static assert( isFunctionOver!(fc, D)); 57 static assert(!isFunctionOver!(fd, C)); 58 static assert( isFunctionOver!(fd, D)); 59 60 import std.math: ceil; 61 static assert( isFunctionOver!(ceil, double)); 62 static assert(!isFunctionOver!(ceil, double, double)); 63 64 static assert(!isFunctionOver!(i)); 65 static assert(!isFunctionOver!(i, int));
Returns true if the passed in function is an n-ary function over the next n parameter arguments
Parameter arguments can be any compile time entity that can be typed.