
On 9/1/06, John Maddock <john@johnmaddock.co.uk> wrote:
Gregory Dai wrote:
Have I got that right?
Well, not completely perhaps. E.g., at least if the target is a std::string of size=0, the resultant std::string may well be reference-counted and shared by multiple threads.
Can you explain some more? Are you saying that if two unrelated threads each default construct a string (or maybe construct a zero length string?) then they will be entangled by reference counting?
Well, I don't have definitive proof, but that's possible from my experience. E.g., we have many classes with ctors like this: ctor(..., std::string const& s = std::string()); More than a few developers had such experience that a crash could well be made disappear by changing the type of "s" to char const* (and, of course, passing whatever the string as string.c_str() to the ctor). We just had too many of it (and for a few other reasons) our solution was eventually replacing std::string with one that does not use the copy-on-write technique. Thanks, John.
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
-- Thanks, Greg