diff options
author | Jakub Jelinek <jakub@redhat.com> | 2022-11-01 13:41:57 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2022-11-01 13:41:57 +0100 |
commit | 81f98afa22815e7397714caf6fa0fc815803ebaa (patch) | |
tree | 582a423d7f04db8e004af5371a0026d8c2bc33e1 /libstdc++-v3/config/abi/pre/gnu.ver | |
parent | 0ae26533b3e26866f4130d40ec0659c273552643 (diff) | |
download | gcc-81f98afa22815e7397714caf6fa0fc815803ebaa.zip gcc-81f98afa22815e7397714caf6fa0fc815803ebaa.tar.gz gcc-81f98afa22815e7397714caf6fa0fc815803ebaa.tar.bz2 |
libstdc++: std::from_chars std::{,b}float16_t support
The following patch adds std::from_chars support, similarly to the
previous std::to_chars patch through APIs that use float instead of
the 16-bit floating point formats as container.
The patch uses the fast_float library and doesn't need any changes
to it, like the previous patch it introduces wrapper classes around
float that represent the float holding float16_t or bfloat16_t value,
and specializes binary_format etc. from fast_float for these classes.
The new test verifies exhaustively to_chars and from_chars afterward
results in the original value (except for nans) in all the fmt cases.
2022-11-01 Jakub Jelinek <jakub@redhat.com>
* include/std/charconv (__from_chars_float16_t,
__from_chars_bfloat16_t): Declare.
(from_chars): Add _Float16 and __gnu_cxx::__bfloat16_t overloads.
* config/abi/pre/gnu.ver (GLIBCXX_3.4.31): Export
_ZSt22__from_chars_float16_tPKcS0_RfSt12chars_format and
_ZSt23__from_chars_bfloat16_tPKcS0_RfSt12chars_format.
* src/c++17/floating_from_chars.cc
(fast_float::floating_type_float16_t,
fast_float::floating_type_bfloat16_t): New classes.
(fast_float::binary_format<floating_type_float16_t>,
fast_float::binary_format<floating_type_bfloat16_t>): New
specializations.
(fast_float::to_float<floating_type_float16_t>,
fast_float::to_float<floating_type_bfloat16_t>,
fast_float::to_extended<floating_type_float16_t>,
fast_float::to_extended<floating_type_bfloat16_t>): Likewise.
(fast_float::from_chars_16): New template function.
(__floating_from_chars_hex): Allow instantiation with
fast_float::floating_type_{,b}float16_t.
(from_chars): Formatting fixes for float/double/long double overloads.
(__from_chars_float16_t, __from_chars_bfloat16_t): New functions.
* testsuite/20_util/to_chars/float16_c++23.cc: New test.
Diffstat (limited to 'libstdc++-v3/config/abi/pre/gnu.ver')
-rw-r--r-- | libstdc++-v3/config/abi/pre/gnu.ver | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/libstdc++-v3/config/abi/pre/gnu.ver b/libstdc++-v3/config/abi/pre/gnu.ver index 729e0cf..1c714fb 100644 --- a/libstdc++-v3/config/abi/pre/gnu.ver +++ b/libstdc++-v3/config/abi/pre/gnu.ver @@ -2448,6 +2448,8 @@ GLIBCXX_3.4.31 { _ZNSt7__cxx1112basic_stringI[cw]St11char_traitsI[cw]ESaI[cw]EE15_M_replace_cold*; _ZSt20__to_chars_float16_tPcS_fSt12chars_format; _ZSt21__to_chars_bfloat16_tPcS_fSt12chars_format; + _ZSt22__from_chars_float16_tPKcS0_RfSt12chars_format; + _ZSt23__from_chars_bfloat16_tPKcS0_RfSt12chars_format; } GLIBCXX_3.4.30; # Symbols in the support library (libsupc++) have their own tag. |