Boost logo

Boost :

From: Samuel Krempp (krempp_at_[hidden])
Date: 2001-12-19 14:39:14


On Wed, 2001-12-19 at 19:35, Peter Dimov wrote:
> Choices.html, first bullet argues that boost::format("...") % expr1 % expr2
> is way cooler than boost::sprintf("...", expr1, expr2).
>
> I don't really have a problem with the % syntax (except for the operator
> precedence, perhaps) but choices.html doesn't do a very good job of
> explaining its benefits.

I wrote this file quickly before the real documentation.
I'll try to explain better the benefits of using operator% (rather than
operator<<)
It's jsut technical.
In one word, it's precisely because it has higher precedence than <<.

And about using operator instead of classical functional arguments
passing, it's easier to explain the benefits so I should be able to make
choices.html clear on this point, at least.

I'll update choices.html soon, I guess this point will be raised many
times and I'll try to write a good answer once and for all.

> One non-obvious advantage of the sprintf-like syntax (the obvious advantage
> is of course sprintf "compatibility") is that sprintf() can detect arity
> errors.

well, format detect arity problems (at run-time, obviously)
I dont understand what you mean here, this is possible with both
approaches.

> Also, I think that the str() free function should be named to_string.

I don't know what is common use for naming free functions, so I'll do as
I'm told on that.
If everybody agree for to_string(..) rather than str(..), why not.

regards,

-- 
Samuel

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