Michiel Helvensteijn wrote:
Aljaz wrote:
I've been wondering if there is no-throw version of boost::program_options::store , command_line_parser and basic_line_parser
I don't believe store() throws any exception. I don't think the basic_line_parser symbol exists in boost.program_options.
As for boost::program_options::basic_command_line_parser<T>.. The run() function of that class must throw an exception in case of parse errors that you need to know about.
If you would like no stack unrolling to take place on error, you just need to surround the call with a try/catch block. If you really don't care about what sort of error it is, you can catch boost::program_options::error.
try { // the function call } catch (boost::program_options::error& e) { // handle error... or don't }
Or you can always also allow unknown options to get through to you, then it won't throw for those, but still for all kinds of other stuff. See basic_command_line_parser::allow_unregistered() in the docs.