diff -r cc9e0c15d747 -r c2ff0a365245 demo/arg_parser_demo.cc --- a/demo/arg_parser_demo.cc Fri Feb 12 22:24:26 2010 +0100 +++ b/demo/arg_parser_demo.cc Sun Feb 14 19:23:55 2010 +0100 @@ -65,9 +65,18 @@ ap.other("infile", "The input file.") .other("..."); + // Throw an exception when problems occurs. The default behavior is to + // exit(1) on these cases, but this makes Valgrind falsely warn + // about memory leaks. + ap.throwOnProblems(); + // Perform the parsing process // (in case of any error it terminates the program) - ap.parse(); + // The try {} construct is necessary only if the ap.trowOnProblems() + // setting is in use. + try { + ap.parse(); + } catch (ArgParserException &) { return 1; } // Check each option if it has been given and print its value std::cout << "Parameters of '" << ap.commandName() << "':\n";