boost.program_options no throw
Hello I've been wondering if there is no-throw version of boost::program_options::store , command_line_parser and basic_line_parser ? Many thanks in advance!
Probably smth, like an std new no-throw:
int* ptr = new(std::nothrow) int(10);
On Wed, Jul 16, 2008 at 6:29 PM, Vladimir Prus
Aljaz wrote:
Hello
I've been wondering if there is no-throw version of boost::program_options::store , command_line_parser and basic_line_parser ?
No. But I don't even understand the question, to be honest. What is that you want?
- Volodya
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
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 } -- Michiel Helvensteijn
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.
participants (5)
-
Aljaz
-
Michiel Helvensteijn
-
Niko Vuokko
-
Ovanes Markarian
-
Vladimir Prus