Boost logo

Boost :

From: Bohdan (warever_at_[hidden])
Date: 2002-10-03 15:18:52


"David B. Held" <dheld_at_[hidden]> wrote in message
news:ani0cb$v06$1_at_main.gmane.org...
> "Bohdan" <warever_at_[hidden]> wrote in message
> news:anhcp3$qsa$1_at_main.gmane.org...
> > I'd like to propose immutable string class, i.e. string that has
> > immutable contents which can be pooled. IMHO immutable_string
> > is better candidate for various "name" properties than std::string.
> > [...]
>
> I'm very interested in this class. What would be nice is a COW
> wrapper for it as well.

if COW == "copy on write" than i do not understand your idea.
immutable_string is ref-counted string and all values are stored in pool
(symbol_table).
Each specific value has only one instance in pool and it has nothing to do
with COW.

> As I understand it, std::string may be
> implemented as ref-counted with COW, but generally is not.

Some stl implementations have ref-counted strings or some variations.

> I have an application where strings will tend to remain the same,
> but I'd like to modify them, even if that means creating a new copy,
> and sharing the old version.
>
> Dave

Still do not understand. Maybe name immutable_string isn't ok.
immutable_string instance can be modified as with normal string:

<code>
      void f( immutable_string & str )
      {
            str = "something else";
      }
</code>

But when you want access value as ::std::string/c-string you can use
str()/c_str() method.

>
>
>
>
>
> _______________________________________________
> Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
>


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk