gpt4 book ai didi

c++ - boost::any_cast 抛出程序选项 c++

转载 作者:行者123 更新时间:2023-11-30 01:06:16 26 4
gpt4 key购买 nike

我有以下代码;

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)

出了什么问题,我该如何解决这个问题?

最佳答案

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));

关于c++ - boost::any_cast 抛出程序选项 c++,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46624725/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com