Boost logo

Boost :

From: Samuel Krempp (krempp_at_[hidden])
Date: 2002-01-30 23:27:44

On Thu, 2002-01-31 at 00:39, Karl Nelson wrote:
> Because most people have no liked use of an operator like << and %,
> I have switched to a printf style for up to 9 arguments. Ie.
> cout << format("%s, %s %d, %d:%.2d\n", weekday, month, day, hour, min);

This is also my favorite.
except, of course, the 9-arguments limitation makes the C++ equivalent
to C's printf look miserable.
(even 100-arguments)

if not for that, I would also have made operator% a member function, say
'with(..)', and provide dozens of N-ary constructors, calling with(..)
on each argument.

and in fact, I did propose on the list to define both a {1,..N}-ary
function call and an operator mechanism for using format.

> And of course arbitrary numbers
> cout << format("%s, %s %d, %d:%.2d\n")(weekday)(month)(day)(hour)(min);
> It supports reordering... (for German translation say)
> cout << format( "%1$s, %3$d. %2$s, %4$d:%5$.2d\n",
> weekday, month, day, hour, min);

This is mostly the same as in the reviewed format library.

The main essential divergence between it and your ofrstream, was the use
of operator<< , because of whose precedence your ofrstream was using
proxy classes; and this is no longer the case.

the choice of the syntax is one of the issues raised during the review,
and still debated.
the general advice is to accept printf format-strings by default, and
maybe provide some other syntax, and actually the final submission I'm
preparing is using printf by default.

your 'group' function is a bit more satisfying than the current 'manip'
Indeed, providing it with {2, .. 10}-ary variants would be the most
satisfying method to pass manipulators along arguments seen until now.
On this aspect, you face the same problem, that prevents the compilation
of :
cout << format("funky %s\n", io::group(hex,10) );
That is because manipulators can not all be passed by const reference.
I had solved that in g++3.0 with T& / T const& overloads, and in MSVC
by passing manipulators by value. (this was discussed in the list)
If we extend it to support up to 9 manipulators at a time, we'd use
by-value for both g++ and MSVC. (else it makes 1000 different functions

Apparently you did not address the painful issues in printf
compatibility (I did not look thoroughly, but at least you implemented
the '0' flag by using '0' as a fill character, which is not enough)

> Documentation to be added after initial feedback.

I'm not sure to understand why you plan to write documentation.
Should I be understanding that your submission is designed as another
candidate to become boost.format, rather than to demonstrate the
feasability of different approaches ?
That's fine with me if you want to build a concurrent candidate, but I
thought elections already had accepted the current pre-version of
Boost.Format, that I have to finalise and submit for final acceptance.
Until my final candidate is submitted to vetoes, I'm taking all advices
and critics to modify the library. And indeed the debate was still very
active in the last few days on both the syntax issue and the method to
use for passing arguments (operator%, '<<', [], .with( ) ...)

I'm reading your code with interest, but for now it might be better to
share your critics, and suggested modifications for the current
candidate, rather than to duplicate efforts.

I plan to upload the final submission within a week, so people should
not have forgotten everything about the library by then.


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