]> git.ipfire.org Git - thirdparty/gcc.git/commit
libstdc++-v3: Some std::*float*_t charconv and i/ostream overloads
authorJakub Jelinek <jakub@redhat.com>
Tue, 1 Nov 2022 12:34:51 +0000 (13:34 +0100)
committerJakub Jelinek <jakub@redhat.com>
Tue, 1 Nov 2022 12:34:51 +0000 (13:34 +0100)
commit29ef50b6bc609130a1550cdfc3997d1e501ffb28
treeca94c6eaf682309b1bafd19952ddc56716ac1d82
parent5cee5f94000ee5eabce9b223c44c7923c1c69f61
libstdc++-v3: Some std::*float*_t charconv and i/ostream overloads

The following patch adds the easy part of <charconv>, <istream> and
<ostream> changes for extended floats.
In particular, for the first one only overloads where the _Float* has
the same format as float/double/long double and for the latter two
everything but the _GLIBCXX_HAVE_FLOAT128_MATH case.
For charconv, I'm not really familiar with it, I'm pretty sure
we need new libstdc++.so.6 side implementation of from_chars for
{,b}float16_t and for to_chars not really sure but for unspecified precision
if it should emit minimum characters that to_chars then can unambiguously
parse, I think it is less than in the float case.  For float128_t
{to,from}_chars I think we even have it on the library side already, just
ifdefed for powerpc64le only.
For i/o stream operator<</>>, not sure what is better, if not providing
anything at all, or doing what we in the end do if user doesn't override
the virtual functions, or use {to,from}_chars under the hood, something
else?
Besides this, the patch adds some further missed
// { dg-options "-std=gnu++2b" }
spots, I've also noticed I got the formatting wrong in some testcases
by not using spaces around VERIFY conditions and elsewhere by having
space before ( for calls.
The testsuite coverage is limited, I've added test for from_chars because
it was easy to port, but not really sure what to do about to_chars, it has
for float/double huge testcases which would be excessive to repeat.
And for i/ostream not really sure what exactly is worth testing.

2022-11-01  Jakub Jelinek  <jakub@redhat.com>

* include/std/charconv (from_chars, to_chars): Add _Float{32,64,128}
overloads for cases where those types match {float,double,long double}.
* include/std/istream (basic_istream::operator>>): Add
_Float{16,32,64,128} and __gnu_cxx::__bfloat16_t overloads.
* include/std/ostream (basic_ostream::operator<<): Add
_Float{16,32,64,128} and __gnu_cxx::__bfloat16_t overloads.
* testsuite/20_util/from_chars/8.cc: New test.
* testsuite/26_numerics/headers/cmath/nextafter_c++23.cc (test):
Formatting fixes.
* testsuite/26_numerics/headers/cmath/functions_std_c++23.cc: Add
dg-options "-std=gnu++2b".
(test_functions, main): Formatting fixes.
* testsuite/26_numerics/headers/cmath/c99_classification_macros_c++23.cc:
Add dg-options "-std=gnu++2b".
libstdc++-v3/include/std/charconv
libstdc++-v3/include/std/istream
libstdc++-v3/include/std/ostream
libstdc++-v3/testsuite/20_util/from_chars/8.cc [new file with mode: 0644]
libstdc++-v3/testsuite/26_numerics/headers/cmath/c99_classification_macros_c++23.cc
libstdc++-v3/testsuite/26_numerics/headers/cmath/functions_std_c++23.cc
libstdc++-v3/testsuite/26_numerics/headers/cmath/nextafter_c++23.cc