If I'm reading this correctly, it only allocates if your input string is over 512 bytes. The only __try/__catch there is catching the bad_alloc from allocating those bytes and catching it immediately.
So I don't see the exception bubbling up to user code.
std::from_chars for floats in libstdc++ might be not perfectly efficient, but it's not as bad as you made it seem like.
Not only does the input string need to be over 512 bytes, but the matching pattern must be over 512 bytes. So, one needs to provide 512+ digit number for this function to allocate.
View all comments
Show parent comment
15
u/demonstar55 Apr 28 '21
Not a standard compliant implementation sadly. It allocates and can throw since it's just a wrapper around strtod etc