[libcxx-commits] [libcxx] [libcxx][locale] Refactor strtonum functions using __str_to_float_c_locale<FloatT> (PR #222081)

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Mon Sep 21 05:47:01 PDT 2026


================
@@ -306,17 +306,17 @@ _LIBCPP_HIDE_FROM_ABI _Tp __do_strtod(const char* __a, char** __p2);
 
 template <>
 inline _LIBCPP_HIDE_FROM_ABI float __do_strtod<float>(const char* __a, char** __p2) {
-  return __locale::__strtof(__a, __p2, __locale::__get_c_locale());
+  return __locale::__str_to_float_c_locale<float>(__a, __p2);
 }
 
 template <>
 inline _LIBCPP_HIDE_FROM_ABI double __do_strtod<double>(const char* __a, char** __p2) {
-  return __locale::__strtod(__a, __p2, __locale::__get_c_locale());
+  return __locale::__str_to_float_c_locale<double>(__a, __p2);
 }
 
 template <>
 inline _LIBCPP_HIDE_FROM_ABI long double __do_strtod<long double>(const char* __a, char** __p2) {
-  return __locale::__strtold(__a, __p2, __locale::__get_c_locale());
+  return __locale::__str_to_float_c_locale<long double>(__a, __p2);
 }
----------------
philnik777 wrote:

Can we remove this and simply call `__locale::__str_to_float_c_locale<T>` below?

https://github.com/llvm/llvm-project/pull/222081


More information about the libcxx-commits mailing list