aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2023-08-16 16:55:00 +0100
committerJonathan Wakely <jwakely@redhat.com>2023-08-17 20:24:17 +0100
commitaeed687f4e08f1364ab60882a012fe740e05a7da (patch)
treecc479e8a6cb79a46f120000175c971d6c50fc068 /gcc
parent51ec07b116b802d845d762beddf8b98e8c0e32ab (diff)
downloadgcc-aeed687f4e08f1364ab60882a012fe740e05a7da.zip
gcc-aeed687f4e08f1364ab60882a012fe740e05a7da.tar.gz
gcc-aeed687f4e08f1364ab60882a012fe740e05a7da.tar.bz2
libstdc++: Implement std::to_string in terms of std::format (P2587R3)
This change for C++26 affects std::to_string for floating-point arguments, so that they should be formatted using std::format("{}", v) instead of using sprintf. The modified specification in the standard also affects integral arguments, but there's no observable difference for them, and we already use std::to_chars for them anyway. To avoid <string> depending on all of <format>, this change actually just uses std::to_chars directly instead of using std::format. This is equivalent, because the format spec "{}" doesn't use any of the other features of std::format. libstdc++-v3/ChangeLog: * include/bits/basic_string.h (to_string(floating-point-type)): Implement using std::to_chars for C++26. * include/bits/version.def (__cpp_lib_to_string): Define. * include/bits/version.h: Regenerate. * testsuite/21_strings/basic_string/numeric_conversions/char/dr1261.cc: Adjust expected result in C++26 mode. * testsuite/21_strings/basic_string/numeric_conversions/char/to_string.cc: Likewise. * testsuite/21_strings/basic_string/numeric_conversions/wchar_t/dr1261.cc: Likewise. * testsuite/21_strings/basic_string/numeric_conversions/wchar_t/to_wstring.cc: Likewise. * testsuite/21_strings/basic_string/numeric_conversions/char/to_string_float.cc: New test. * testsuite/21_strings/basic_string/numeric_conversions/wchar_t/to_wstring_float.cc: New test. * testsuite/21_strings/basic_string/numeric_conversions/version.cc: New test.
Diffstat (limited to 'gcc')
0 files changed, 0 insertions, 0 deletions