2017-05-27 23:46 GMT+02:00 Adrian Wielgosik <adrian.wielgo...@gmail.com>: > Currently std::to_string takes a fairly long trip to vs(n/w)printf. The patch > implements int-to-string formatting in header, to improve function > performance.
The existing specification of std::to_string is specified in a way that would make this replacement implementation non-conforming, IMO. Reason for this is, that the C++ specification says: "Each function returns a string object holding the character representation of the value of its argument that would be generated by calling sprintf(buf, fmt, val) with a format specifier of "%d", "%u", "%ld", "%lu", "%lld", "%llu", "%f", "%f", or "%Lf", respectively, where buf designates an internal character buffer of sufficient size." The explicit reference to sprintf without specification of any locale means that the outcome should depend on the currently set locale, so a conforming program could notice the difference by either calling std::setlocale. This is different for the new "primitive numeric output" functions (std::to_chars, std::from_chars), which explicitly require a conversion as if the "C" locale would be active. - Daniel