Boost logo

Boost :

From: John Torjo (john.lists_at_[hidden])
Date: 2004-04-22 08:15:51

Jeremy Maitin-Shepard wrote:

>One of the significant advantages to using formatting facilities like
>*printf or Boost Format is that messages with embedded value placement
>indicators can be stored as a single string, which makes translation of
>such message strings much, much easier. Thus, much of the benefit of
>such a facility is lost when the ability to represent message strings
>as single strings is lost.
I know that, it's really common sense.

I'm only thinking of using str_stream() for debugging/logging.
(p.s. - indeed, I should have specified this in the original post ;))
In this case, it does make a lot of sense (at least to me).

Just think how easy it is to say something like:
throw std::runtime_error(str_stream() << "invalid line at idx " << idx);

as opposed to something like
throw std::runtime_error(io::str(format("invalid line at idx %1%) % idx)));

I think the former is more readable.

It's not just that. It's also the fact that str_stream is **lightweight**.
Have you taken a look at the implementation of boost::format?
Don't get me wrong - I love boost::format. In fact I use it a lot. But
for simple things I use simple classes.

As a side note, you can also use it like this:
std::string s = str_stream(idx);


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