Boost C++ Libraries: Ticket #4510: [program_options]: implicit_value and positional options conflict https://svn.boost.org/trac10/ticket/4510 <p> Hello, </p> <p> Thanks for a great library. I just updated to 1.43 and it appears options with implicit values no longer work if there are also positional options. </p> <p> In fact libs/src/program_options/example/options_description.cpp fails in 1.43: </p> <pre class="wiki">1.43% options_description --verbose foo in option 'verbose': invalid option value </pre><p> In 1.38 this worked fine </p> <pre class="wiki">1.38% options_description --verbose foo Input files are: foo Verbosity enabled. Level is 1 Optimization level is 10 Listen port is 0 </pre><p> I briefly looked at the library source code and see new code added in cmdline.cpp: </p> <pre class="wiki"> /* If an key option is followed by a positional option, can can consume more tokens (e.g. it's multitoke option), give those tokens to it. */ ... </pre><p> It seems that in order to make implicit options work in presence of positional options, the semantic()-&gt;max_tokens() function must return 0, that is, you can never specify a value for an implicit option. I don't know if this is desired, but it will work for me. </p> <p> Thank you, </p> <p> Soren Soe </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/4510 Trac 1.4.3 mdecker6@… Mon, 29 Dec 2014 19:49:19 GMT <link>https://svn.boost.org/trac10/ticket/4510#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4510#comment:1</guid> <description> <p> Is anyone going to fix this? Everything is pretty much as Soren says. </p> <p> As for if this was desired, this is not how it is documented and not how this typically should behave. That is, options with implicit_values should never consume positional options. Never being able to specify a value for an implicit value, negates the purpose of implicit values (as these can be accomplished with just bool_switch) and there is no other option that I can think of to do this. </p> <p> Here is the documentation for reference: </p> <p> Specifies an implicit value, which will be used if the option is given, but without an adjacent value. Using this implies that an explicit value is optional, but if given, must be strictly adjacent to the option, i.e.: '-ovalue' or '--option=value'. Giving '-o' or `--option' will cause the implicit value to be applied. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Vladimir Prus</dc:creator> <pubDate>Mon, 29 Dec 2014 20:10:40 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/4510#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4510#comment:2</guid> <description> <p> Probably the most reliable way to get this fixed is to submit a pull request; otherwise it won't get fixed for at least two weeks of upcoming public holidays, and then maybe some time more. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Mon, 29 Dec 2014 20:17:42 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/4510#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4510#comment:3</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/4510#comment:2" title="Comment 2">vladimir_prus</a>: </p> <blockquote class="citation"> <p> Probably the most reliable way to get this fixed is to submit a pull request; otherwise it won't get fixed for at least two weeks of upcoming public holidays, and then maybe some time more. </p> </blockquote> <p> Ok, cool. Thank you. </p> </description> <category>Ticket</category> </item> </channel> </rss>