Filling up a FormatSpec

rumbu rumbu at rumbu.ro
Tue Jan 2 21:01:03 UTC 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.


More information about the Digitalmars-d-learn mailing list