我有以下代码;
using namespace std;
using namespace boost::program_options;
using namespace boost::filesystem;
using namespace cv;
namespace fs = boost::filesystem;
int frames2skip;
options_description desc("Allowed options");
desc.add_options();
("frames2skip", value<int>(&frames2skip)->default_value(2));
variables_map opts;
store(parse_command_line(argc, argv, desc), opts);
frames2skip = opts["frames2skip"].as<int>();
在最后一行分配'frames2skip'
后,我收到以下错误:
what(): boost::bad_any_cast: failed conversion using boost::any_cast
Aborted (core dumped)
有什么问题以及如何解决这个问题?
答案 0 :(得分:5)
desc.add_options();
// ^ rogue semicolon, the next line is a separate statement made up
// of parenthesized comma-expression and has no effect on `desc`.
("frames2skip", value<int>(&frames2skip)->default_value(2));