Providing custom formatting without importing half of phobos.

rumbu via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Nov 9 08:48:40 PST 2015


On Monday, 9 November 2015 at 16:11:23 UTC, H. S. Teoh wrote:
> On Mon, Nov 09, 2015 at 03:09:26PM +0000, rumbu via 
> Digitalmars-d-learn wrote:
>> [...]
>
> Do you need *custom* format specifiers? If all you need is to 
> be able to write: format("%s", myData), then the only thing you 
> need to do is to implement one of the toString methods 
> recognized by format(), such as:
>
> 	void toString(scope void delegate(const(char)[]) dg) {
> 		...
> 	}
>
> and format() should be able to just pick it up.
>
>
> T
I'm working to create a decimal data type library, therefore I 
need at least %f %e %a and %g, including other data like width, 
precision and so on.


More information about the Digitalmars-d-learn mailing list