Boost logo

Boost :

From: Karl Nelson (kenelson_at_[hidden])
Date: 2002-02-11 16:17:31


> > > Does this really add a whole lot of value
> > > cout << format("%{1:hex,width=10,pad=0} %{2:dec}")(a)(b);
> > > over
> > > cout << format("%010x %d")(a)(b);
> >
> > It certainly does.
>
> I'm starting to like MS' formatting approach where
>
> format("{2} is {1:fmt}", x, y)
>
> is translated into
>
> to_string(y) + " is " + to_string(y, "fmt").
>
> This combined with a default formatter that understands printf-like syntax
> would look like
>
> format("{2:10} is {1:6.3f}", "test", 0.5);

That is perfectly compatiable with using a printf frontend if
you just add a %...

   format("%10s is %6.3f","test", 0.5)

means same as
   format("%{1:10s} is %{2:6.3f}", "test", 0.5)
is
   to_string("test","10s") + " is " + to_string(0.5,"6.3f")

The hook to do that isn't that hard to add to format3.
  
> Naturally, the default formatter would be user-replaceable, enabling people
> to add verbosity as desired.

--Karl


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk