I’m very new to C++, boost etc.
I would like to know if there is already a function in boost or STL I can use to determine if a string is numeric.
Numeric strings may look like:
100
or
100.52
I know there are tons of examples how to write such a function but I would like to know if there is already a function I can use for this.
I’m looking for a pure C++-solution, not C.
[UPDATE:
I’m already using lexical_cast to convert my strings, I’m just wondering if there is a method like is_numeric I can use for this…]
No, there’s not a ready-made way to do this directly.
You could use
boost::lexical_cast<double>(your_string)orstd::stod(your_string)and if it throws an exception then your string is not a double.C++11:
Boost: