diff -r 7c4ba7daaf5f -r 2b6bffe0e7e8 demo/arg_parser_demo.cc --- a/demo/arg_parser_demo.cc Tue Dec 20 17:44:38 2011 +0100 +++ b/demo/arg_parser_demo.cc Tue Dec 20 18:15:14 2011 +0100 @@ -2,7 +2,7 @@ * * This file is a part of LEMON, a generic C++ optimization library. * - * Copyright (C) 2003-2009 + * Copyright (C) 2003-2010 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport * (Egervary Research Group on Combinatorial Optimization, EGRES). * @@ -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";