Boost C++ Libraries: Ticket #5201: Negative numbers as options and values not parsed correctly https://svn.boost.org/trac10/ticket/5201 <p> This issue has been reported initially on <a class="missing wiki">StackOverflow</a> in question <a class="ext-link" href="http://stackoverflow.com/questions/4107087/accepting-negative-doubles-with-boostprogram-options"><span class="icon">​</span>Accepting negative doubles with boost::program_options</a> and later reminded on the mailing list in thread <a class="ext-link" href="http://lists.boost.org/Archives/boost/2011/02/176604.php"><span class="icon">​</span>program_options negative numbers</a>. Not sure if it is a bug or lack of feature, but seems it would be reasonable to have it solved. </p> <p> Simply, program_options can not parse negative numbers as values of options. For example: </p> <pre class="wiki">mycommand --extent -1.0 -2.0 -3.0 1.0 2.0 3.0 --some-other-argument somevalue </pre><p> I discussed this issue with Volodya on IRC and there seems to be possible and not difficult to implement solution. Here is the chat script: </p> <pre class="wiki">Nov 10 17:04:17 &lt;mloskot&gt; volodya: I think it's feasible to refactor the loops in the cmdline parser to handle multitoken options with negative numbers as values. I have an idea to add ::multitoken(int exact_tokens_num) and make parser consuming as much values as the exact number of tokens specified, regardless how the options look like Nov 10 17:04:26 &lt;mloskot&gt; volodya: what you think about this idea? Nov 10 17:04:28 &lt;spitzi&gt; The question is - supposed that I want to make some quick-and-dirty struct for the sake of having related, named fields tied together, but without going through writing c'tors and operators. Can a list of such structs be initialized with boost::assign::list_of ? Nov 10 17:05:30 &lt;volodya&gt; mloskot: well, I think that if that translates into min and max number of tokesn of the option being equal to that value, it seems sane Nov 10 17:05:53 &lt;mloskot&gt; volodya: yes, basically that would be the thing Nov 10 17:05:55 &lt;volodya&gt; and of course, when min=max, there's no need to guessing. Nov 10 17:05:59 &lt;volodya&gt; ok, sounds good. </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/5201 Trac 1.4.3 Georg Sauthoff <mail@…> Sun, 19 Jan 2014 17:58:39 GMT cc set https://svn.boost.org/trac10/ticket/5201#comment:1 https://svn.boost.org/trac10/ticket/5201#comment:1 <ul> <li><strong>cc</strong> <span class="trac-author">mail@…</span> added </li> </ul> Ticket