lexical_cast int to string

前端 未结 3 1517
耶瑟儿~
耶瑟儿~ 2021-02-19 16:22

Is it safe to ignore exception of boost::lexical_cast when converting int to std::string?

3条回答
  •  北海茫月
    2021-02-19 17:01

    If you "ignore" an exception it will propagate back up the call stack until it is caught elsewhere, or it terminates the program, the point being you can safely not catch exceptions without worrying about you program continuing and doing unsafe/unknown things (as long as a "crash" to command prompt is acceptable error behaviour or you have some other way of dealing with unknown exceptions).

    Unfortunately exception stack traces aren't so easy to get in C++, so creating useful error messages when exceptions aren't caught locally isn't always easy.

提交回复
热议问题