Problem with program_options store()
Given this program fragment (based on the Getting Started example) using Boost::program_options compiled with MinGW:
options_description desc("Program options");
...
variables_map vm;
store(parse_command_line(argc, argv, desc), vm);
gave the following error (reformatted for readability):
error: no matching function for call to
`store(boost::program_options::basic_parsed_options<const char>,
boost::program_options::variables_map&)'
candidates are:
store(const boost::program_options::basic_parsed_options<char>&,
boost::program_options::variables_map&, bool)
store(const boost::program_options::basic_parsed_options
Hi Merrill,
Given this program fragment (based on the Getting Started example) using Boost::program_options compiled with MinGW:
options_description desc("Program options"); ... variables_map vm; store(parse_command_line(argc, argv, desc), vm);
Please always provide a complete program! The snippet copied from docs is likely to be correct, the problem might be in outside code that you did not provide.
gave the following error (reformatted for readability):
error: no matching function for call to `store(boost::program_options::basic_parsed_options<const char>, boost::program_options::variables_map&)'
candidates are: store(const boost::program_options::basic_parsed_options<char>&, boost::program_options::variables_map&, bool)
store(const boost::program_options::basic_parsed_options
&, boost::program_options::variables_map&) I can add a "true" as a third argument to store(), but the mismatch still remains in the first argument: <const char> versus <char>&.
If I assigned the result of parse_command_line() to an intermediate variable, I can match the &, but the const char versus char still remains.
What is the problem way of calling store()?
How is you main declared? The C++ standard say it should be int main(int ac, char* av[]) Note: "char", not "const char". This is the most likely problem. - Volodya
participants (2)
-
Merrill Cornish
-
Vladimir Prus