Tech Off Post

Single Post Permalink

View Thread: Why are string types immutable in C#?
  • User profile image
    Mike Dimmick

    amotif wrote:
    Is that the case or does std::string implement copy-on-write like MFC does? (I'm a little concerned that I no longer remember...)

    The C++ standard does not mandate any reference-counting or string-sharing behaviour for std::string. As far as I can tell the version shipped with VS.NET 2003 does not do it.

    One of the problems with refcounted strings is making them threadsafe. This normally leads to a lot of overhead for the more common case of a string that's never accessed concurrently from different threads.