po::options_description desc("This are the options that are available");
desc.add_options()("help", "print help")(
"deer", po::value<uint32_t>(), "set how many deer you want")(
"rating", po::value<uint32_t>(), "how good ?")(
"name", po::value<std::string>(), "and your name is ... ?");
po::variables_map vm;
po::store(po::parse_command_line(argc, argv, desc), vm);
po::notify(vm);
in a following section of the code I tried to iterate over vm
for (const auto& it : vm) {
std::cout << it.first.c_str() << " "
<< it.second.as<it.pair::second_type>() << "\n";
}
The main point here is that vm
contains keys
of the same type, but values with different types, in this example I have uint32_t
mixed with a std::string
.
How I can iterate over this kind of containers ? I would like to avoid a verbose approach so I'm trying to just iterate over this data structure.
EDIT:
I forgot to write this down, but obviously
namespace po = boost::program_options;