Using boost/program_options
in c++, when I build the options_description
I specify each option's type (fs::path
in this case):
namespace fs = boost::filesystem;
namespace po = boost::program_options;
po::options_description desc("Example");
desc.add_options()
("help", "Print help messages")
("input,i", po::value<fs::path>(), "Input folder");
and I build the variables_map
po::variables_map vm;
po::store(po::parse_command_line(argc, argv, desc), vm);
When I access the option I have to specify again their type:
vm["input"].as<fs::path>()
and not
vm["input"]
Is there some more handy way of accessing the variables map?
Can't boost take advantage from the fact that I already specified the type of the variable_value
stored in vm
?
I saw that many programmers end up in storing the option in another variable
fs::path input = vm["input"].as<fs::path>()
but I would like to avoid defining redundant variables.