开发者

boost::program_options - Is is possible to enforce mandatory flag?

开发者 https://www.devze.com 2023-02-01 20:17 出处:网络
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.,

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?


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")
    ;
0

精彩评论

暂无评论...
验证码 换一张
取 消