On Friday, 1 April 2016 at 23:26:14 UTC, Alex Parrill wrote:
On Friday, 1 April 2016 at 21:25:46 UTC, Yuxuan Shui wrote:
[...]

Not as-is, because the format string is a runtime argument and not a compile-time constant.

Consider:

    writefln(rand() >= 0.5 ? "%s" : "%d", 123);

It's certainly possible with a new, templated writef function. Hypothetically:

    writefln_ctfe!"%s"(1234); // would fail

That's kind of ugly. Now I really wish D can unify template arguments and function arguments known at compile time.

Reply via email to