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

via libcxx-commits libcxx-commits at lists.llvm.org
Sun Sep 20 02:46:34 PDT 2026


================
@@ -307,17 +307,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, _LIBCPP_GET_C_LOCALE);
+  return __locale::__str_to_float_c_locale<float>(__a, __p2, _LIBCPP_GET_C_LOCALE);
----------------
Himadhith wrote:

Also worth noting before when we passed `__loc` to `__locale_guard __current(__loc);` it did not have any problems. But now when we pass `__locale_guard __current(__get_c_locale());` it errors out saying:
```
 _LIBCPP_HIDE_FROM_ABI __locale_guard(locale_t& __loc) : __old_loc_(::uselocale(__loc)) {}
```
Now I can either do it as 
```
__locale_t __c = __get_c_locale();
__locale_guard __current(__c);
```
Or change it in the `__locale_guard` to take `__locale_t` by value rather than `locale_t&`. 

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


More information about the libcxx-commits mailing list