
On Wed, Jan 26, 2011 at 5:37 PM, Yakov Galka <ybungalobill@gmail.com> wrote:
Excuse my ignorance, but can someone explain to me why people are so keen on immutable strings? Aren't they basically the same as 'shared_ptr<const std::string>'?
Nope. For one, an immutable string doesn't have to be stored in a contiguous thunk of memory. It can share common parts across instances, it can -- and probably should -- be implemented as a segmented container, and interning immutable strings is a popular way of getting crazy performance gains on different kinds of applications with relatively modest costs. These things you don't get with just a shared_ptr<std::string const>. :) Add to that the capability to use/define a "sane" memory management solution and you'd have a pretty good competitor to good old std::string. :) -- Dean Michael Berris about.me/deanberris