@@ -255,6 +255,13 @@ ftms = {
ftms = {
name = to_chars;
+ values = {
+ v = 202306;
+ cxxmin = 26;
+ extra_cond = "_GLIBCXX_FLOAT_IS_IEEE_BINARY32 "
+ "&& _GLIBCXX_DOUBLE_IS_IEEE_BINARY64 "
+ "&& __SIZE_WIDTH__ >= 32";
+ };
values = {
v = 201611;
cxxmin = 14;
@@ -62,6 +62,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
#if __cplusplus > 201703L && __cpp_impl_three_way_comparison >= 201907L
friend bool
operator==(const to_chars_result&, const to_chars_result&) = default;
+#endif
+#if __cplusplus > 202302L
+ constexpr explicit operator bool() const noexcept { return ec == errc{}; }
#endif
};
@@ -74,6 +77,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
#if __cplusplus > 201703L && __cpp_impl_three_way_comparison >= 201907L
friend bool
operator==(const from_chars_result&, const from_chars_result&) = default;
+#endif
+#if __cplusplus > 202302L
+ constexpr explicit operator bool() const noexcept { return ec == errc{}; }
#endif
};
new file mode 100644
@@ -0,0 +1,21 @@
+// { dg-do run { target c++26 } }
+
+#include <charconv>
+#include <testsuite_hooks.h>
+
+void
+test_result()
+{
+ static_assert( ! std::is_convertible_v<std::from_chars_result, bool> );
+ static_assert( std::is_constructible_v<bool, std::from_chars_result> );
+
+ std::from_chars_result res{};
+ VERIFY( res );
+ res.ec = std::errc::invalid_argument;
+ VERIFY( !res );
+}
+
+int main()
+{
+ test_result();
+}
new file mode 100644
@@ -0,0 +1,25 @@
+// { dg-do run { target c++26 } }
+
+#include <charconv>
+#include <testsuite_hooks.h>
+
+#if defined(__cpp_lib_to_chars) && __cpp_lib_to_chars < 202306L
+# error "Feature-test macro for std::to_chars has wrong value in <charconv>"
+#endif
+
+void
+test_result()
+{
+ static_assert( ! std::is_convertible_v<std::to_chars_result, bool> );
+ static_assert( std::is_constructible_v<bool, std::to_chars_result> );
+
+ std::to_chars_result res{};
+ VERIFY( res );
+ res.ec = std::errc::invalid_argument;
+ VERIFY( !res );
+}
+
+int main()
+{
+ test_result();
+}
@@ -6,7 +6,7 @@
#ifndef __cpp_lib_to_chars
# error "Feature-test macro for to_chars missing in <version>"
-#elif __cpp_lib_to_chars != 201611L
+#elif __cpp_lib_to_chars != (__cplusplus == 202302L ? 201611L : 202306L)
# error "Feature-test macro for to_chars has wrong value in <version>"
#endif