When using boost::program_options, how do I set the name of an argument for boost::program_options::value<>()?
#include
The program_options::value_semantic class doesn't parameterize the argument name, so I think you will have to define your own class. Something like this:
struct my_arg_type
: public boost::program_options::typed_value
{
my_arg_type(std::string const& name)
: boost::program_options::typed_value(&my_value)
, my_name(name)
, my_value(0)
{
}
std::string name() const { return my_name; }
std::string my_name;
int my_value;
};
boost::program_options::options_description desc;
my_arg_type arg("foo");
desc.add_options()
("width", &arg, "give width");
This should give something like:
--witdh foo give width