[Bug libstdc++/59439] std::locale uses atomic instructions on construction
redi at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Dec 10 23:59:00 GMT 2013
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59439
--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Don't do that then ;-)
Noone ever claimed std::stringstream is a good way to convert integers to
strings in performance critical code. Even if the std::locale construction is
optimized further, stringstream still involves far more code than necessary for
a simple conversion (to handle field widths, hex output and everything else
that iostreams support).
std::to_string() is a better alternative in C++11, re-using an existing
stringstream object is another alternative, or just use your snprintf version.
There's a good reason boost::lexical_cast is special-cased for the common
int-to-string conversions that don't need fancy formatting.
More information about the Gcc-bugs
mailing list