Opened 16 years ago

Closed 13 years ago

#821 closed Feature Requests (worksforme)

allow_unregistered improvement

Reported by: axet Owned by: Vladimir Prus
Milestone: Component: program_options
Version: None Severity: Showstopper
Keywords: Cc:

Description

po::variables_map vm;
po::parsed_options parsed = po::command_line_parser(argc, argv).options(cmdline_options).allow_unregistered().run();
po::remove_unrecognized(parsed);
po::store(parsed, vm);


namespace boost
{
  namespace program_options
  {
	template <class T> bool is_unrecognized ( T &value ) {
	  return value.unregistered;
	}

	template <class T> void remove_unrecognized_options(T &op)
	{
	  T::iterator end=std::remove_if(op.begin(),op.end(),is_unrecognized<T::value_type>);
	  op.erase(end,op.end());
	}

	template <class T> void remove_unrecognized(T &op)
	{
	  remove_unrecognized_options(op.options);
	}
  }
}

Change History (3)

comment:1 by Steven Watanabe, 14 years ago

Component: functionalprogram_options
Severity: Showstopper

comment:2 by Steven Watanabe, 14 years ago

Owner: changed from mark_rodgers to Vladimir Prus
Status: assignednew

comment:3 by Vladimir Prus, 13 years ago

Resolution: Noneworksforme
Status: newclosed

I do not think this is now necessary, given that 'store' ignores unrecognized options itself.

Note: See TracTickets for help on using tickets.