Last active
July 29, 2020 16:49
-
-
Save jll63/d6575d2ec5318c355f164e529453db73 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
template Params(alias fun) { | |
static if (is(typeof(fun) P == __parameters)) { | |
alias Params = P; | |
} | |
} | |
template forward(alias fun) { | |
static foreach(idx, overload; __traits(getOverloads, __traits(parent, fun), __traits(identifier, fun))) | |
@(__traits(getAttributes, overload)) auto forward(Params!overload p) { | |
return fun(p); | |
} | |
} | |
@("foo") | |
void myfun(int a, ref double b, out string c) { | |
b += 5.0; | |
c = "omg"; | |
} | |
int myfun(in string a, inout double b) { | |
return 40; | |
} | |
import core.stdc.time; | |
void set (time_t value = time(null)) { | |
import std.stdio; | |
writeln(value); | |
} | |
void main() { | |
double b = 4.3; | |
string s = "asdas"; | |
forward!myfun(4, b, s); | |
forward!set(); | |
import std.stdio; | |
writeln(b, s); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment