I have an input file (ASCII) with arithmetics, e.g.
TEST;0.0;0.0+0.1;0.0+0.2
I can read the string and split it accordingly, so I already have elements of std::string
. Now I wanted to use boost::lexical_cast<double>
to store it in a double, comparable to an expression like:
double d = boost::lexical_cast<double>("0.0+0.1");
However, Boost throws
terminate called after throwing an instance of 'boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::bad_lexical_cast> >'
what(): bad lexical cast: source type value could not be interpreted as target
Is there a good way to go, maybe without sscanf
? (If sscanf
would be capable of doing this at all...)
TIA