
If I have a parameter which needs a value, but the value is not specified in the command line, I get an unknown exception in VisualStudio 2005. Meaning, if I declare a --compression=something, but then call the program with just --compression, the exception is thrown at the po::store() method. How do I intercept this and validate? I am just using the code from the example program: po::options_description desc("Allowed options"); desc.add_options() ("help", "produce help message") ("compression", po::valuestd::string(), "set compression level") ; po::variables_map vm; po::store(po::parse_command_line(ac, av, desc), vm); po::notify(vm); if (vm.count("help")) { std::cout << desc << "\n"; return 1; } if (vm.count("compression")) { std::cout << "Compression level was set to " << vm["compression"].asstd::string() << ".\n"; } else { std::cout << "Compression level was not set.\n"; }