Boost logo

Boost :

From: Ross Smith (r-smith_at_[hidden])
Date: 2001-12-20 19:09:29


Samuel Krempp wrote:
>
> On Thu, 2001-12-20 at 22:20, Karl Nelson wrote:
>
> > This is much more clear in my mind than
> >
> > cout << format("%1 %2") % 1 % 2 << endl;
> >
> > Which mixes one stream concept with another. Mixed notation like that
>
> No. on one side, the stream, and its <<.
>
> On the other side, the format object, getting its argument via
> successive calls to operator%.
>
> the operator% here is just a way to get arbitrary number of arguments,
> nothing more.
>
> It's a concept that has nothing to do with streams, or formatting, or
> whatever. It's more general, and a much simpler concept than streams.
>
> BTW, I guess there will sooner or later be other libraries who'll need
> the same kind of mechanism for passing arbitrary number of arguments.
> Why would we not begin using operator% now to express this concept ?
> (or another operator, you name it, I use it..)

In some of my code I've been using repeated function call operators to
provide arbitrary numbers of arguments. Something like this:

    cout << format("%1 %2")(1)(2) << endl;

I like it becaues it bears a reasonable resemblance to a real variadic
function, and it doesn't overload an arbitrarily-chosen operator that
might suggest something else to the reader.

-- 
Ross Smith ...................................... Auckland, New Zealand
r-smith_at_[hidden] ......................... http://storm.net.nz/~ross/
  "We need a new cosmology. New gods. New sacraments. Another drink."
                                                       -- Patti Smith

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