diff --git a/demo/arg_parser_demo.cc b/demo/arg_parser_demo.cc --- a/demo/arg_parser_demo.cc +++ b/demo/arg_parser_demo.cc @@ -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";