Is std::to_string thread safe?
std::to_string
behaves as if it calls sprintf
([string.conversions]/7), and the behavior of sprintf
depends on the global locale, which can be modified by setlocale
(or by std::locale::global
, which internally calls setlocale
).
The wording in [clocale.syn]/2 seems to imply that std::to_string
is thread safe, because it does not allow setlocale
to introduce a data race with std::to_string
or sprintf
.