【发布时间】:2012-02-08 20:06:48
【问题描述】:
我一直在尝试使用 boost::program_options 验证我通过的选项。我的命令有几种模式,每种模式都有可以指定的相关参数。我要做的是确保这些关联的参数与模式一起传递,即
unicorn --fly --magic-wings-threshold
其中--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"
)
那我就不能用了
if (vm.count("magic-wings-threshold")( {
// do stuff
}
检测用户是否传递了该参数。
似乎总是在vm.count() 中传递和检测默认值参数。有谁知道解决方法或替代方法?
【问题讨论】:
-
所有我熟悉的独角兽都不会飞,也没有翅膀。也许你在想飞马?
标签: c++ boost boost-program-options