Boost logo

Boost :

Subject: [boost] [program_options] custom validator overrides
From: Roger Martin (roger_at_[hidden])
Date: 2018-10-15 23:11:39


The Custom Validators documentation

void validate(boost::any& v,
               const std::vector<std::string>& values,
               magic_number* target_type, int)

but the possible templates don't match; the last variable type is an
int; the key is matching this last type:

int goes with std::vector<T>*

long goes with T*

it also seems possible to hit the

 Â Â Â  void validate(boost::any& v,
 Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â  const std::vector<std::basic_string<charT> >& s,
 Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â  boost::optional<T>*,
 Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â  int)
 Â Â Â  {

where it then calls for get_single_string and if you are trying for a
multitokens switch args, it'll throw " only takes a single argument".

which also varies if it was parsed by command_line_parser or

command_line_parser: vector size can >= 1 up to number of switch args

parse_config_file: vector size ==1 no matter what the number of args are
on the input.  just one string with all switch args.

This was tested with 1.65 yet I don't see anything changing in

Boost list run by bdawes at, gregod at, cpdaniel at, john at