
Hi, I want to implement the --switch / --no-switch behavior. I defined a bool option "switch" and then I parse the command line with an extra parser that sets "switch" to "false" if it finds a --no-switch. myopts.add_options() ("switch", po::value<bool>()->implicit_value(true), "Use switch.") ; po::store (po::command_line_parser(argc, argv).options(all).extra_parser(parse_no_options).run(), vm); The extra parser is: std::pair<std::string, std::string> parse_no_options (const std::string& s, const std::string name) { if (s.find("--switch") != s.npos) { if (s.substr (2, 3) == "no-") return std::make_pair (s.substr (5), std::string("false")); else return std::make_pair (s.substr (2), std::string("true")); } return std::make_pair (std::string(), std::string()); } This works fine for the command line. I also need to implement this for the config file, but I do not know how to pass the extra parser to the parse_config_file. Is there a way? Thanks, Marti