boost program_options是否支持关闭开关(例如——no-myswitch或-s=no)

Does boost program_options support off-switches (e.g. --no-myswitch or -s=no)

本文关键字:no-myswitch 例如 no 开关 options program 是否 支持 boost      更新时间:2023-10-16

当我为程序定义布尔开关时,例如

("foo,f", "frobnicate")

我想说

myprogram --foo
myprogram --no-foo
myprogram --foo=no

或者至少,第一个和第二个或第三个中的一个。program_options支持这个吗?还是我必须"手动"定义这些开关?

您必须自己定义它们。

库告诉你在命令行上给出了哪些选项,然后由你来将这些选项映射到特性/标志/任何东西。因此,它不会告诉你功能/标志/任何东西是"开"还是"关";