
29 Jun
2006
29 Jun
'06
1:08 p.m.
Is there anything in Boost which I can use to convert a more descriptive string like "60%" to a double?
The real answer is I don't know but maybe something like the following should do: double str_to_double(const std::string& s) { assert(!s.empty()); if(str[str.size() - 1] == '%') return str_to_double(s.substr(0, s.size() - 2)); return boost::lexical_cast<double>(s) / 100.0; }