boost::any_cast 使用程序选项 C++ 抛出
boost::any_cast throw with program options c++
我有以下代码;
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));
相关文章:
- 如何在提升程序选项中设置矢量<矢量>的默认值<string>
- C++ 使用 json 文件提升程序选项
- 提升程序选项:链接错误
- 提升程序选项的多个选项值
- 在任务管理器的应用程序选项卡中获取运行任务的列表
- 获取提升程序选项以在函数范围之后保留
- boost::any_cast 使用程序选项 C++ 抛出
- clang-format用于提升程序选项
- 提升程序选项:参数被多次检测到
- 提升程序选项:自定义验证器是否需要重载运算符>>?
- C ++提升程序选项始终给出默认值
- 使用提升程序选项通过配置文件/命令行解析自定义对象
- 将参数从升压程序选项导出到doxygen
- 使用Boost程序选项读取相对文件路径
- 使用提升程序选项处理 2 级命令的最佳方法
- 如何使用Boost程序选项提取已解析选项的序列
- 提升程序选项对价值
- 在程序选项中添加键值对
- 提升程序选项 添加选项语法
- 提升 1.57.0 程序选项 MSVS 2013 链接器错误