aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/include/std/version
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2022-03-11 14:36:18 +0000
committerJonathan Wakely <jwakely@redhat.com>2022-03-16 16:06:29 +0000
commit5a4e208022e7047af3a15a3dedb715ad801db160 (patch)
treeb90f70e422a851cc62500bd4073b7adce848f5b1 /libstdc++-v3/include/std/version
parentbeb12c62eaec37ed0ee5a251ca0907d965d413b2 (diff)
downloadgcc-5a4e208022e7047af3a15a3dedb715ad801db160.zip
gcc-5a4e208022e7047af3a15a3dedb715ad801db160.tar.gz
gcc-5a4e208022e7047af3a15a3dedb715ad801db160.tar.bz2
libstdc++: Ensure that std::from_chars is declared when supported
This adjusts the declarations in <charconv> to match when the definition is present. This solves the issue that std::from_chars is present on Solaris 11.3 (using fast_float) but was not declared in the header (because the declarations were guarded by _GLIBCXX_HAVE_USELOCALE). Additionally, do not define __cpp_lib_to_chars unless both from_chars and to_chars are supported (which is only true for IEEE float and double). We might still provide from_chars (via strtold) but if to_chars isn't provided, we shouldn't define the feature test macro. Finally, this simplifies some of the preprocessor checks in the bodies of std::from_chars in src/c++17/floating_from_chars.cc and hoists the repeated code for the strtod version into a new function template. N.B. the long double overload of std::from_chars will always be defined if the float and double overloads are defined. We can always use one of strtold or fast_float's binary64 routines (although the latter might produce errors for some long double values if they are not representable as binary64). libstdc++-v3/ChangeLog: * include/std/charconv (__cpp_lib_to_chars): Only define when both from_chars and to_chars are supported for floating-point types. (from_chars, to_chars): Adjust preprocessor conditions guarding declarations. * include/std/version (__cpp_lib_to_chars): Adjust condition to match <charconv> definition. * src/c++17/floating_from_chars.cc (from_chars_strtod): New function template. (from_chars): Simplify preprocessor checks and use from_chars_strtod when appropriate.
Diffstat (limited to 'libstdc++-v3/include/std/version')
-rw-r--r--libstdc++-v3/include/std/version3
1 files changed, 2 insertions, 1 deletions
diff --git a/libstdc++-v3/include/std/version b/libstdc++-v3/include/std/version
index 461e65b..d730a7e 100644
--- a/libstdc++-v3/include/std/version
+++ b/libstdc++-v3/include/std/version
@@ -171,7 +171,8 @@
#endif
#define __cpp_lib_shared_ptr_weak_type 201606L
#define __cpp_lib_string_view 201803L
-#if _GLIBCXX_HAVE_USELOCALE
+#if _GLIBCXX_FLOAT_IS_IEEE_BINARY32 && _GLIBCXX_DOUBLE_IS_IEEE_BINARY64 \
+ && __SIZE_WIDTH__ >= 32
# define __cpp_lib_to_chars 201611L
#endif
#define __cpp_lib_unordered_map_try_emplace 201411L