Boost logo

Boost :

From: Cédric Venet (cedric.venet_at_[hidden])
Date: 2007-06-19 03:00:03

Quoting Jeremy Maitin-Shepard <jbms_at_[hidden]>:

> Rene Rivera <grafikrobot_at_[hidden]> writes:
>> You just described the Boost.Format library.
> The boost format library may be pretty good. It could presumably be
> adapted to work on top of a different set of backend facilities for
> formatting various types to character strings/streams, as opposed to
> being based on the iostreams system,

boost.format seems to be unknow or not liked, anyways, it didn't seems
like a reference. However, it should solve a majority of the need.
Just it's not efficient (somethings like 3 or 4 times slower that
printf from the doc if I recall correctly). For most application, this
wouldn't be a problem. But sometimes it can. we could imagine
something like:

cout << format("var ",_s," =3D ",_h<8>,";")%v.n%v.v << endl;
cout << format("var ",_s," =3D ",_h<8>,";")(v.n,v.v) << endl;
cout << format("var "%_s%" =3D "%_h<8>%";",v.n,v.v) << endl;

where _s and _h are respectively string and hex integer, the
positionnal and format option could be passed as template or runtime

for user defined type outputing, either use << like boost.format or
define another free funtion which could take additional parameter like
formating option

template<class T,class OPT>
void toString(stream& os, T t, OPT opt) {

this shouldn't be too slow at compile time, but I fear a little code
bloating. There is then a tradeoff speed/size by selecting runtime or
compile time parameter.

Cédric Venet
Jeremy, Sorry for the double post (I dislike this webmail wich ignore  
the reply-to)

Boost list run by bdawes at, gregod at, cpdaniel at, john at