相关疑难解决方法(0)

使用vm.count()时,使用默认值提升程序选项

我一直试图用boost :: program_options来验证我传递的选项.我的命令有几种模式,每种模式都有可以指定的相关参数.我要做的是确保这些相关的参数以模式传递,即

unicorn --fly --magic-wings-threshold
Run Code Online (Sandbox Code Playgroud)

--fly模式在哪里,--magic-wings-threshold是一个相关的参数.我注意到的是,如果--magic-wings-threshold有一个默认值,例如

("magic-wings-threshold,w", po::value<double>(&wings_thresh)->default_value(0.8, "0.8"),
           "Magic wings maximum power"
)
Run Code Online (Sandbox Code Playgroud)

那我就不能用了

if (vm.count("magic-wings-threshold")( {
    // do stuff
}
Run Code Online (Sandbox Code Playgroud)

检测用户是否通过了该参数.

似乎总是传递和检测默认值参数vm.count().有没有人知道变通方法或替代方案?

c++ boost boost-program-options

15
推荐指数
1
解决办法
3312
查看次数

标签 统计

boost ×1

boost-program-options ×1

c++ ×1