In general, if you need speed, consider this library:
http://www.fastformat.org/
(I'm not sure if it contains functions for converting strings or streams to other types, though, so it may not answer your current example).
For the record, please note you're comparing apples to oranges here. strtod()
is a simple function that has a single purpose (converting strings to double), while stringstream is a much more complex formatting mechanism, which is far from being optimized to that specific purpose. A fairer comparison would be comparing stringstream to the sprintf/sscanf line of functions, which would be slower than strtod()
but still faster than stringstream. I'm not exactly sure what makes stringstream's design slower than sprintf/sscanf, but it seems like that's the case.