Alternative to boost::lexical_cast

后端 未结 7 1098
粉色の甜心
粉色の甜心 2020-12-30 06:27

I\'m taking a part in a challenge, and just to cut to the point, in one of places in my program I need to convert string to an integer. I\'ve tried boost::lexical_cast but u

相关标签:
7条回答
  • 2020-12-30 06:59

    You could do it using sscanf but I suspect it's slower than atoi as it handles locales.

    You'll definitely be interested in reading this C++ Convert String to Int Speed benchmark that features a naive implementation that is faster than atoi.

    EDIT: Another post comparing different string to int implementations: C++ String to Int.

    0 讨论(0)
提交回复
热议问题