Hacker News new | past | comments | ask | show | jobs | submit login

This makes sense for integers but beware floating point from_chars - libc++ still doesn't implement it and libstdc++ implements it by wrapping locale-dependent libc functions which involves temporarily changing the thread locale and possibly memory allocation to make the passed string 0-terminated. IMO libstdc++'s checkbox "solution" is worse than not implementing it at all - user's are better off using Lemire's API-compatible fast_float implementation [0].

Of course it's possible that the author wanted to support compilers released before 2018 when that code was written in which case not even integer from_chars would be available.

[0] https://github.com/fastfloat/fast_float




Hm. Good to know! What about strtof?


the strtoX functions have been around for many, many years, and should be completely reliable. but i would use strtod. in fact i never use floats in my code unless i am dealing with very large numbers of floating-point values.




Consider applying for YC's W25 batch! Applications are open till Nov 12.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: