|
Boost : |
From: Karl Nelson (kenelson_at_[hidden])
Date: 2002-02-11 18:22:47
> > > > 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").
>
> I also like this. It has the advantages of 'printf' (terse readable
> syntax) combined with the advantage of iostreams (user extensibility).
> Another advantage is that it yields a string directly, so you can do
> things like 'widget.set_label(<format_expression>)'.
I believe this is already possible with format3 code base
widget.set_label(format("foo %s %d","hello",1).to_string());
The question whether there should be an automatic conversion.
Generally the feeling is that that would be bad practice.
--Karl
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk