From: Beman Dawes (bdawes_at_[hidden])
Date: 2001-06-29 12:12:52
At 11:42 AM 6/29/2001, Samuel Krempp wrote:
>I updated the files, as format2 now reaches "version 1.0"
>It is earned because it now has complete support of the desired printf
>That is, I added the '+', and ' ' flags.
>As well as an extra flag, '=' to indicate 'centered adjustment'.
>Also format now behaves correctly when a manipulator puts the stream in
>internal adjustment (fill characters goes between sign/basefield and rest
>of the number)
>So it is now possible to do
>cout << format("[%=6s] [%+6s] [%+6s] [% 6s] [%+6s] [%s]\n") % 123
> * internal * setfill('W') % 234
> * internal * setfill('X') % -345
> * setfill('Y') % 456
> * setfill('Z') % -10
> % "foo"
> % "invisible extra argument" << "bar.\n";
>which prints :
>[ 123 ] [+WW234] [-XX345] [YY 456] [ZZZ-10] [foo]
I missed the original discussions some months back, but just looking at
your example above,
* Very Interesting work!
* The choice of arithmetic operators "*" and "%" is totally unsettling to
my eye. Let's try it with "<<":
cout << format("[%=6s] [%+6s] [%+6s] [% 6s] [%+6s] [%s]\n") << 123
<< internal << setfill('W') << 234
<< internal << setfill('X') << -345
<< setfill('Y') << 456
<< setfill('Z') << -10
That seems ever so much better if you can pull it off.
* Having a disappearing argument ("invisible extra argument") seems like a
bad idea; most likely it is a coding error so should not be silent, IMO.
* Like Dave (in another message), I really hate sticky formatting; it has
caused me a lot of past grief.
I hope you will continue to develop "format". Seems like a very nice
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk