
7 Mar
2011
7 Mar
'11
4:37 p.m.
Jeffrey Lee Hellrung, Jr. wrote:
Another concern with COW in general is iterator invalidation.
This is the only concern. The moment you allow non-const iterators into your potentially shared representation, you have to think very carefully about specifying when these are invalidated (the correct answer is "on any operation"). std::string has this problem; since CoW is deemed an implementation detail there, obtaining a non-const iterator or reference into a string disables sharing for this string forever (because you can't track the lifetime of the iterator or reference).