On Tue, Oct 9, 2012 at 12:13 AM, bearophile <[email protected]> wrote: > Maybe someone someday will want to implement two Phobos printing functions > usable like this: > > writecfln!"%d %s"(10, "hello"); > writecf!"%d %s"(10, "hello"); > > They accept a format string as template argument (format strings are often > compile-time constants and sometimes they are computable on the fly at > compile-time), verifies at compile time (calling another CTFE function in > its template constraint) that the format string matches with the type tuple > of the arguments, and then just call writefln()/writef() with the format > string and arguments.
IIRC, I did that as an example in my template tutorial: https://github.com/PhilippeSigaud/D-templates-tutorial/blob/master/dtemplates.pdf?raw=true (section 32, on page 167) Code in https://github.com/PhilippeSigaud/D-templates-tutorial/blob/master/templates_examples.tex#L2000 and below.
