Boost logo

Boost :

From: Karl Nelson (kenelson_at_[hidden])
Date: 2000-08-21 19:12:37


> Karl,
>
> I am beginning to like your proposal more and more. I think I would "insist"
> on having a wide version for boost. I also think there are simple ways we
> can produce the fully templatized version that will work with the current
> gcc lib (but only for narrow streams in that environment) by using
> appropriate full specialization.

Yes, I agree that a a wide version definitely would have to be
written once the details of the current became clear. It would
not be all that much effort to make a config file of some sort
to allow the API to work on gcc and more standard versions at the
same time.

 
> One other question: is it really neccessary to have a separate format() and
> string_format() in the usage syntax? It seems (without looking at the
> details) like you could make the following work:
>
> cout << format("The Truth is %^20s\n")
> << (format("%f != %f") << 1 << 2);
> cout << format("The Truth is %^25s\n") << setfill('.')
> << (format("%.5f != %f) << 1.9999 << 2.000 );
>
> The key is that you can have separate return types (X and Y) for
>
> X operator<<(ostream&, const <type-of-format>&)
>
> and
>
> template <class T>
> Y operator<<(const <type-of-format>&, T)

I did think about this one a bit but decided to propose
the string_format() instead.

 
> Am I onto something here or am I speaking from a "dark place"?

This isn't a dark place, but rather just a bit of ambiguity.
My current implementation used two formats in a row to mean
"dump current and use this one". However, that functionality
could be dumped in place of the other meaning. Also one would have
to ask is the current behavior that extra arguments are placed
in the stream appropriate as well.

  cout << format("%d %d") << i << j << format("%d %d") << k << l;

(is the second format bad because the first one forgot the endf
or should the second flow to the first?)

Note that I could achieve the same thing you describe by
just making a conversion from format to string, this would give....

 format::operator string(); (or basic_string for template version.)

 cout << format("The Truth is %^25s\n") << setfill('.')
      << string(format("%.5f != %f) << 1.9999 << 2.000 );

Which actually is a bit more meaningful. (take a format
and make a string for use on the first format statement.)

Is that acceptable?

--Karl


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