News for hackers. Stuff that matters.
Re:A C++ Immutable String class by cdmh on Saturday September 21, 2013 @03:35PM (#6424149)
21.4.1 p6 states invalidation of iterators/references is only allowed for — as an argument to any standard library function taking a reference to non-const basic_string as an argument. — Calling non-const member functions, except operator[], at, front, back, begin, rbegin, end, and rend.

The non-const operator[] in a COW string requires making a copy of the string if the ref count > 1 which invalidates references and violates this paragraph.

Re:A C++ Immutable String class by nly on Saturday September 21, 2013 @03:55PM (#6424227)
Hmm true. This is what happens when you let the user violate the iterator abstraction for performance and rely on contiguity and raw refs/ptrs. It's kind of a shame, because the moment you mutating characters in a string you're often doing something silly anyway.