January 02, 2018
Is there any way to parse a format string into a FormatSpec?

FormatSpec has a private function "fillUp" which is not accessible.

I need to provide formatting capabilities to a custom data type, I've already written the standard function:

void toString(C)(scope void delegate(const(C)[]) sink, FormatSpec!C fs) const

but I want to provide another function:

string toString(C)(const(C)[] fmt) and forward it to the standard one.

The problem is that initializing FormatSpec with fmt does not parse it:

auto fs = FormatSpec!C(fmt); //this will just put fmt in fs.trailing

I know that I can use format() for this, but I don't want to import 6000 code lines, I would prefer to interpret myself FormatSpec once parsed.