[libcxx-commits] [PATCH] D59178: [libc++] Speedup to_string and to_wstring for integers using stack buffer and SSO
Afanasyev Ivan via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Mar 21 08:44:57 PDT 2019
ivafanas added a comment.
In D59178#1436754 <https://reviews.llvm.org/D59178#1436754>, @mclow.lists wrote:
> Now that revision 356585 has landed, we can use `std::to_chars` to implement `to_string`
> I would suggest something like (untested code):
> template <class T>
> string __to_chars(T t)
> char buf[numeric_limits<T>::digits10() + 3]; // +1 for '-' +1 for nul, and +1 for extra
> to_chars_result res(buf, buf + sizeof(buf), t, 10);
> return string(buf, res.ptr);
> and then call *that* from the various `to_string` implementations.
I've started implementing and testing `to_string` via `to_chars` and realized that `to_chars` doesn't support `wchar_t` unlike `to_wstring`.
I'm going to extend `__to_chars_itoa` implementation in order to support `wchar_t` and reuse those internal template function.
Could you please confirm that this way is ok in order not to through away the third attempt on completion.
CHANGES SINCE LAST ACTION
More information about the libcxx-commits