Is std::string thead-safe with gcc 4.3?

后端 未结 6 1415
野性不改
野性不改 2020-12-05 00:46

I\'m developing a multithreaded program running on Linux (compiled with G++ 4.3) and if you search around for a bit you find a lot of scary stories about std::string not bei

6条回答
  •  猫巷女王i
    2020-12-05 01:01

    This section of the libstdc++ internals states:

    The C++ library string functionality requires a couple of atomic operations to provide thread-safety. If you don't take any special action, the library will use stub versions of these functions that are not thread-safe. They will work fine, unless your applications are multi-threaded.

    The reference counting should work in a multi-threaded environment. (unless your system doesn't provide the necessary atomics)

提交回复
热议问题