Alternative to boost::lexical_cast

后端 未结 7 1175
粉色の甜心
粉色の甜心 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条回答
  •  猫巷女王i
    2020-12-30 06:41

    For the Google Summer of Code I'm working on a new Boost library to tackle this; boost::coerce which can be found over here. The backend builds upon boost::spirit providing you all of its advantages (speed in particular) with a much simpler interface:

    int i = boost::coerce::as("23");
    

    or

    std::string s = boost::coerce::as(23);
    

    Note that it is still a work in progress, but should be sufficiently stable in practice. If any problems arise, please let me know.

提交回复
热议问题