08.07.2019 13:38, Joseph Rushton Wakeling пишет:
Thanks for taking the time to answer, but I don't think this really
addresses my question.
Your example shows a struct with `toString` overloads. However,
SysTime.toISOExtString does not work like this: it is a method with two
explicit overloads, one of which just returns a newly allocated
`string`, the other of which returns nothing but accepts an output range
as input:
https://dlang.org/phobos/std_datetime_systime.html#.SysTime.toISOExtString
I want to know if there's an easy way to work with that in `format` and
`writefln` statements.
Note that while SysTime does also have `toString` methods, these give no
control over the kind of datetime string that results:
https://dlang.org/phobos/std_datetime_systime.html#.SysTime.toString
Since I explicitly need the extended ISO format, I need to use
`toISOExtString` directly.
Sorry that my answer wasn't thoughtful.
I guess that there is no way to have `writeln` automatically use the
output range overload instead of allocating one. You need somehow to
provide the output range to `toISOExtString` explicitly because
`writeln` outputs the return of `toISOExtString` and have no ability to
use specific overload. That is compiler calls `toISOExtString` and then
passes its return to `writeln`. Probably library solution isn't possible
in this case. Workaround is using own wrapper to provide output range to
`toISOExtString`.