Created
August 3, 2017 11:49
-
-
Save zaydek-old/6575442a74927c280349abb2bbd37a87 to your computer and use it in GitHub Desktop.
This file contains hidden or 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, core.stdc.stdlib; | |
void main() | |
{ | |
} | |
/+ | |
cache | |
+/ | |
static struct cache | |
{ | |
static File file; | |
/+ | |
opCall | |
+/ | |
static opCall(T...)(T args) if (!is(typeof(args[0]) == File)) | |
{ | |
if (!file.isOpen) | |
file = stdout; | |
return file == stdout || file == stderr ? opCall!(true)(file, args) : opCall(file, args); | |
} | |
/+ | |
opCall | |
+/ | |
static opCall(bool std = false, T...)(File file, T args) | |
{ | |
static if (!is(typeof(args[0]) == string)) | |
file.writeln (args); | |
else | |
file.writefln(args); | |
if (file != stdout && file != stderr) | |
file.flush(); | |
static if (!std) { writeln("hello"); file.flush(); } | |
return (ubyte code = 1) => exit(code); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment