logoalt Hacker News

aw1621107today at 3:36 PM1 replyview on HN

The changes to std::string were made because "the [pre-C++11] definition of basic_string allows only very limited concurrent access to strings. Such limited concurrency will inhibit performance in multi-threaded applications." The proposed fix was to make "all iterator and element access operations safely concurrently executable." [0]. This involved limiting the circumstances in which iterators could be invalidated, which among other things meant that non-const operator[] could no longer invalidate iterators, which meant copy-on-write was no longer a viable implementation [1].

[0]: https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n26...

[1]: https://stackoverflow.com/q/12199710


Replies

jdw64today at 4:27 PM

Thank you for the kind comment. !