Definitive answer about thread-safety of std::string

Chad Attermann chad@broadmind.com
Thu Nov 15 19:18:00 GMT 2007


While libstdc++ documentation makes it clear that the library is thread-safe 
as long as an object is locked so that only a single concurrent thread can 
access it, I have seen some conflicting statements elsewhere that elude to 
the fact that std::string may be safe for access by concurrent threads.  I 
would appreciate if anyone could enlighten me on whether std::string is in 
fact safe for access by concurrent threads without explicit locking, or if 
it requires a read-write locks or a full locks instead.

Regards,

Chad.



More information about the Libstdc++ mailing list