Boost logo

Boost :

Subject: Re: [boost] [string] proposal
From: Dean Michael Berris (mikhailberis_at_[hidden])
Date: 2011-01-26 09:37:26

On Wed, Jan 26, 2011 at 5:37 PM, Yakov Galka <ybungalobill_at_[hidden]> 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>'?


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

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