
On 3/6/06, Nigel Stewart <ns@fluent.com> wrote:
But I think that filling a string instead of returning a temporary one is always faster. And there is another reason for avoiding allocation apart from speed: memory fragmentation.
Something not yet mentioned in this thread - the Qt QString provides a reference-counted "shallow-copy", (deep-copy on modification) mechanism that makes QString a lot more efficient than std::string in this kind of situation. Copying a QString is cheap, and sizeof(QString)==sizeof(int).
GNU's libstdc++'s std::string is reference counted as well. Has there been any boost proposal for alternative strings
to std::string?
There was a fixed_string library that was reviewed recently, but it was rejected. -- Caleb Epstein caleb dot epstein at gmail dot com