
How expensive is it to parse numbers from a string in C++? - ingve
https://lemire.me/blog/2019/10/26/how-expensive-is-it-to-parse-numbers-from-a-string-in-c/
======
davismwfl
I am not sure what the author was really trying to communicate, other than
proving again that stringstream is the slowest way of parsing numbers from
strings in C++.

Using the stringstream is convenient but it is never advised for a performance
focused application. This is a known situation and is why other std::
functions exist which are significantly more performant. And if you really
need more performance there are still other ways to achieve it. Not to mention
just including stringstream drastically affects program size since that thing
is a beast.

I guess for new C++ people this may not be known though so is worth
demonstrating, but I would think showing this versus std::stoi vs atoi etc
would communicate tradeoffs better. Safety being one tradeoff you need to
account for when using stoi/atoi and custom methods.

------
jandeboevrie
Why would he not use std::stoi?

