[libcxx-commits] [PATCH] D59178: [libc++] Speedup to_string and to_wstring for integers using stack buffer and SSO
Marshall Clow via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Mar 20 11:20:56 PDT 2019
mclow.lists requested changes to this revision.
mclow.lists added a comment.
This revision now requires changes to proceed.
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.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D59178/new/
https://reviews.llvm.org/D59178
More information about the libcxx-commits
mailing list