Last active
October 9, 2015 18:04
-
-
Save nin-jin/e52e51a68e5a6b17c6fb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import std.stdio; | |
T eval( string op , T )( T a , T b ) { | |
return mixin( q{a} ~ op ~ q{b} ); | |
} | |
unittest { | |
writeln( eval!q{/}( 123 , 0 ) ); | |
} | |
//object.Error@(0): Integer Divide by Zero | |
//---------------- | |
//0x0040BA03 in pure nothrow @nogc @safe int xxx.eval!("/", int).eval(int, int) at /xxx/xxx.d(4) | |
//0x004031CC in void xxx.__unittestL7_8() at /xxx/xxx.d(8) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import std.stdio; | |
mixin template makeX() { | |
auto x = ( int a ){ | |
return 1 / a; | |
}; | |
} | |
unittest { | |
mixin makeX; | |
writeln( x(0) ); | |
} | |
// object.Error@(0): Integer Divide by Zero | |
// ---------------- | |
// 0x004031E5 in pure nothrow @nogc @safe int xxx.__unittestL9_8().__mixin1.__lambda2(int) at /xxx/xxx.d(5) | |
// 0x004031D1 in void xxx.__unittestL9_8() at /xxx/xxx.d(11) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment