On Friday, 8 May 2015 at 22:29:28 UTC, Biotronic wrote:
Sadly, the ... syntax precludes the use of __LINE__ and __FILE__. :(

You can put them in the runtime parameters:

----
void traceVars(alias T, U...)(size_t line = __LINE__, string file = __FILE__) {
    import std.stdio : writeln;
    writeln(file, "(", line, ") ", T.stringof, ": ", T);
    static if (U.length > 0) {
        traceVars!(U)(line, file);
    }
}
----

Or you can nest two templates:

----
template traceVars(alias T, U...) {
void traceVars(size_t line = __LINE__, string file = __FILE__)() {
        import std.stdio : writeln;
        writeln(file, "(", line, ") ", T.stringof, ": ", T);
        static if (U.length > 0) {
            alias t = .traceVars!U;
            t!(line, file);
        }
    }
}
----

Reply via email to