Jean-Marc Lasgouttes wrote:
> Angus> These patches work around a bug in the gcc 2.95 STL
> Angus> implementation. Committing now.
> 
> Could you tell me again why using stringstreams instead of good old
> string concatenation is better in this case? I guess Lars already
> mentioned it, but it looks like more complications to me.

Shrug. There's a lot more copying involved in this:

vector<string> data;
string result;
for (int i=0; i<data.size(); ++i) {
    if (i!=0)
        result += ':';
    result += data[i];
}

when compared to this:

vector<string> data;
ostringstream ss;
for (int i=0; i<data.size(); ++i) {
    if (i!=0)
        ss << ':';
    ss << data[i];
}
string const result = ss.str();

But the net result is the same. The use case above is exactly the sort of 
thing that stringstreams were designed for, no?

-- 
Angus

Reply via email to