[libcxx-commits] [PATCH] D64341: [libcxx] speedup to_string for floating point numbers

Afanasyev Ivan via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Mon Jul 8 21:27:57 PDT 2019


ivafanas added a comment.

In D64341#1574437 <https://reviews.llvm.org/D64341#1574437>, @mclow.lists wrote:

> I would like to hold this for a while; because in a few weeks, we should have an implementation of `to_chars` for floating point - which we may be able to use in `to_string` (like we did for the integral types).


Hi Marshall,

I'm not sure there is a way to reuse `to_chars` for floating point numbers inside `to_string` function due to locale issues:

- `to_string` must produce the same output as `sprintf` with `%f` or `%Lf` format specifiers (N. 7, 8, 9 and note 3 <https://en.cppreference.com/w/cpp/string/basic_string/to_string>)
- `sprintf` is locale-dependent. I suppose there is a difference between comma and point character for locales. Maybe something more.
- `to_chars` must produce the same result as `sprintf` in the default ("C") locale (N. 2 <https://en.cppreference.com/w/cpp/utility/to_chars>)

If there is a tricky way to get around problem with locale dependency it would be nice.


Repository:
  rCXX libc++

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64341/new/

https://reviews.llvm.org/D64341





More information about the libcxx-commits mailing list