#include <bits/error_constants.h> // for std::errc
#include <ext/numeric_traits.h>
-// FIXME: Define when floating point is supported:
-// #define __cpp_lib_to_chars 201611L
+#if _GLIBCXX_HAVE_USELOCALE
+# define __cpp_lib_to_chars 201611L
+#endif
namespace std _GLIBCXX_VISIBILITY(default)
{
#endif
#define __cpp_lib_shared_ptr_weak_type 201606
#define __cpp_lib_string_view 201803L
-// #define __cpp_lib_to_chars 201611L
+#if _GLIBCXX_HAVE_USELOCALE
+# define __cpp_lib_to_chars 201611L
+#endif
#define __cpp_lib_unordered_map_try_emplace 201411
#define __cpp_lib_variant 201606L
#endif
// Test std::from_chars floating-point conversions.
-// As of July 2020 __cpp_lib_to_chars is not defined, but std::from_chars
-// works for floating-point types when _GLIBCXX_HAVE_USELOCALE is defined.
-#if __cpp_lib_to_chars >= 201611L || _GLIBCXX_HAVE_USELOCALE
+#if __cpp_lib_to_chars >= 201611L
void
test01()
{
int
main()
{
-#if __cpp_lib_to_chars >= 201611L || _GLIBCXX_HAVE_USELOCALE
+#if __cpp_lib_to_chars >= 201611L
test01();
test02();
test03();
// Test std::from_chars error handling.
-// As of July 2020 __cpp_lib_to_chars is not defined, but std::from_chars
-// works for floating-point types when _GLIBCXX_HAVE_USELOCALE is defined.
-#if __cpp_lib_to_chars >= 201611L || _GLIBCXX_HAVE_USELOCALE
+#if __cpp_lib_to_chars >= 201611L
void
test01()
{
int
main()
{
-#if __cpp_lib_to_chars >= 201611L || _GLIBCXX_HAVE_USELOCALE
+#if __cpp_lib_to_chars >= 201611L
test01();
test02();
test03();
void
test01()
{
-#if __cpp_lib_to_chars >= 201611L || _GLIBCXX_HAVE_USELOCALE
+#if __cpp_lib_to_chars >= 201611L
#if _GLIBCXX_USE_C99_FENV_TR1
double d;
std::fesetround(FE_DOWNWARD);
// Verifies correctness of the hexadecimal form [BEGIN,END) for VALUE by
// round-tripping it through from_chars (if available).
auto verify_via_from_chars = [] (char *begin, char *end, long double value) {
-#if __cpp_lib_to_chars >= 201611L || _GLIBCXX_HAVE_USELOCALE
+#if __cpp_lib_to_chars >= 201611L
long double roundtrip;
auto result = from_chars(begin, end, roundtrip, chars_format::hex);
VERIFY( result.ec == errc{} );