boost program_options multiple values problem

杀马特。学长 韩版系。学妹 提交于 2019-12-03 07:58:11
small_duck

For the "default_value" method, the first parameter is the real value that you wish your option to be, the second value being only the textual representation (for display in --help) when boost cannot infer it.

So, the solution to your problem is to write:

po::value< vector<string> >()->default_value(
      vector<string>(1, "SOMETHING"), "SOMETHING")->composing(),

This way, you are saying that the default value is a vector with a single element "SOMETHING", and that you want to display "SOMETHING" in the help, such as:

Configuration:
  --optimization arg (=10)              optimization level
  -I [ --include-path ] arg (=SOMETHING)
                                        include path
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!