boost::program_options - 是否可以强制执行强制标志?

发布于 2024-10-09 23:10:06 字数 97 浏览 0 评论 0原文

我在程序中使用 boost::program_options 。我想强制使用某个标志。是否可以使用 program_options 来执行此操作,使其自行强制执行?即抛出错误消息?

I'm using boost::program_options in my program. I want to make a certain flag mandatory. Is is possible to do this with program_options in a way that it'll enforce this itself? i.e., throw an error message?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夜未央樱花落 2024-10-16 23:10:06

根据文档 您可以在选项描述中指定一个选项是必需的:

options_description desc;
desc.add_options()
    ("help", "produce help")
    ("count", value<int>()->required(), "number of executions")
    ;

According to the documentation you can specify that an option is required in the option description:

options_description desc;
desc.add_options()
    ("help", "produce help")
    ("count", value<int>()->required(), "number of executions")
    ;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文