D-Programming-Language/phobos — pull request #1516 by quickfur (2013-08-25 06:11:54+00:00)
Title: Fix issue 10881: support writefln("%f") of complex numbers

It appears that the original toString implementation already supported format specs like %f, but it appears to be out-of-sync with the latest std.format so that writefln("%f", complex(...)) doesn't work.

So, rewrite toString to use the up-to-date std.format API for supporting custom format specifiers. Added a bunch of unittests and code examples.

I left the original toString intact, but just redirecting the actual formatting logic to the new toString, just in case some external code actually relied on it, since it was actually documented in detail. It can probably be removed if no user code depends on it, since it appears to be an attempt to integrate with an older version of std.format, but the current std.format no longer picks up on its function signature so it's quite useless now. But just to be safe and prevent breaking existing D code, I left it intact.