Is it safe to ignore exception of boost::lexical_cast
when converting int
to std::string
?
boost::lexical_cast is an alternative to functions like std::stoi(), std::stod(), and std::to_string(), which were added to the standard library in C++11. Now let see the Implementation of this function in a program. Examples: Conversion integer -> string string- > integer integer -> char float- > string.
In C++, the stoi() function converts a string to an integer value. The function is shorthand for “string to integer,” and C++ programmers use it to parse integers out of strings. The stoi() function is relatively new, as it was only added to the language as of its latest revision (C++11) in 2011.
Exception raised by lexical cast when converting an int
to std::string
are not associated to the conversion, but to resource unavailable. So you can ignore this in the same way you ignore the exception bad_alloc
raised by operator new.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With