How expensive is it to parse numbers from a string in C++?
lemire.me
lemire.me
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.