
Hello, I have the following questions, I have breifly scoured the archive but haven't quite found what I want, so if this already been covered please point me in the direction. desc.add_options() ("port", po::value<string>(), "port to connect to"); I have looked at modifiers for value_semantic, one_token() multi_token() is there such a concept as required ? such that for e.g. desc.add_options() ("port", po::value<string>()->required(), "port to connect to"); causes the parser to 'die' if the value port isn't defined ? currently I am using vm.count("port") to deduce whether it has been defined. My other question is, why does the type have to be specified when extracting something from the variable map ? for e.g. vm["port"].as<string>() ... when it has already been defined in the configurations options. I ask this because I have a function that I am using: bool check_key(po::variables_map &vm, string key, bool required, bool print) { if (required && !(vm.count(key))) { cerr << "fatal: " << key << " not defined." << endl; exit(1); } if (print && vm.count(key)) { cout << key << ": " << vm[key].as<string>() << endl; } } This incidentally solves my first problem of having a key(option) defined or failing if it does not exist in the variable map, but ... say if I have a option defined as po::value<int>() inside option_description then my my function fails ... as it tries to interpret it as a string ? Is there a better way to do this ? cheers, ravi