
Peter Dimov wrote:
Alexander Terekhov wrote:
Yeah, simply put, mutations of std::string object may invalidate references and iterators (with COW inspired semantics for non- const operator[]() et al. )... threads or no threads, COW or no COW.
Umm, not exactly.
int x = s[0];
(with non-const s) does not invalidate if COW isn't used,
Uhmm, that's not what the standard says. Well, apart from http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#263 http://groups-beta.google.com/group/comp.lang.c++.moderated/msg/1fc8476dbadf... I suggest you simply read between the lines of "These rules are formulated to allow, but not require, a reference counted implemenation. A reference counted implementation must have the same semantics as a non-reference counted implementation" note having efficient COW implementation in your mind. (Among other things I mean invalidation on refcount > 1 with refcount == 0 representing unshareable state.) ;-) regards, alexander.