Boost logo

Boost :

Subject: Re: [boost] Variadic append for std::string
From: Olaf van der Spek (ml_at_[hidden])
Date: 2017-01-11 10:03:36

On Wed, Jan 11, 2017 at 10:02 AM, Christof Donat <cd_at_[hidden]> wrote:

> Hi,
> Am 11.01.2017 09:28, schrieb Olaf van der Spek:
>> On Tue, Jan 3, 2017 at 4:55 PM, Christof Donat <cd_at_[hidden]> wrote:
>>> I know, but you came up with C++ beginners. They already often get
>>> confused
>>> with streams and bit shifts, mostly when they come to C++ from C. Now we
>>> additionally mix expressions, where we can use manipulators with those,
>>> where we can't. That will probably make things worse not only for C++
>>> beginners.
>> Maybe, maybe not.
>> Overloading yet another operator for a similar (but not equal) purpose is
>> problematic too.
> That is true. Actually I think, the best option is a different class, that
> behaves just like a stream. Then it'll support manipulators, etc. No one
> will be surprised, that strings behave similar to streams, but not really
> the same, etc. We already have that class in the standard library:
> std::ostringstream.
> BTW: boost::format follows that same pattern as well. It just doesn't use
> the shift operator to prevent confusion with stream.
> I think << is quite elegant.
>>> I feel very uneasy with it and I think I have presented quite some
>>> reasoning why.
>> You have, but I don't think we have a significantly better alternative.
> The significantly better alternative is std::ostringstream. I think our
> debate showed very nicely, that all the options, we have come up with to
> simplify the concatenation of strings are significantly inferior in total,
> though we could find examples, where they slightly improve readability.

Interface is important, as is performance.. and performence of
ostringstream sucks..


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