1 static assert( !hasBasicMathOp!int ); // can't get int from expr(int * double)
2 static assert( hasBasicMathOp!float );
3 static assert( hasBasicMathOp!double );
4 static assert( hasBasicMathOp!real );
5 static assert( hasBasicMathOp!cfloat );
6 static assert( !hasBasicMathOp!char );
7 static assert( !hasBasicMathOp!string );
8
9 static struct TTest
10 {
11 float x,y;
12 auto opBinary(string op)( in TTest v ) const
13 if( op=="+" || op=="-" )
14 { return TTest(x+v.x,y+v.y); }
15 auto opBinary(string op)( double v ) const
16 if( op=="*" || op=="/" )
17 { return TTest(x*v,y*v); }
18 }
19
20 static assert( hasBasicMathOp!TTest );
21
22 struct FTest
23 {
24 float x,y;
25 auto opAdd( in TTest v ) const { return TTest(x+v.x,y+v.y); }
26 }
27
28 static assert( !hasBasicMathOp!FTest );
checks has type T basic math operations
* isAssignable!(Unqual!T,T) * is( typeof( T.init + T.init ) == T ) * is( typeof( T.init - T.init ) == T ) * is( typeof( ( T.init * 0.5 ) ) : T ) * is( typeof( ( T.init / 0.5 ) ) : T )