Jeroen Habraken wrote
Vladimir Batov wrote
Or I'll just run raw Spirit.Qi example from http://www.kumobius.com/2013/08/c-string-to-int/
#include <string> #include <boost/spirit/include/qi_parse.hpp> #include <boost/spirit/include/qi_numeric.hpp>
bool String2Int(const std::string& str, int& result) { std::string::const_iterator i = str.begin(); if (!boost::spirit::qi::parse(i, str.end(), boost::spirit::int_, result)) return false; return i == str.end(); // ensure the whole string was parsed }
That's a nice solution, and should save quite a bit of headache.
Deployed the above code directly in a loop and via converter. Ubuntu 14.04. gcc 4.8.2. Compiled with -O3. Ran te test quite a few times: str-to-int spirit: raw/cnv=0.89/0.89 seconds. str-to-int spirit: raw/cnv=0.89/0.89 seconds. str-to-int spirit: raw/cnv=0.89/0.89 seconds. str-to-int spirit: raw/cnv=0.89/0.89 seconds. The code to review is in the post_review branch. Corrections welcome. -- View this message in context: http://boost.2283326.n4.nabble.com/review-Convert-library-tp4662821p4662901.... Sent from the Boost - Dev mailing list archive at Nabble.com.