|
Boost Users : |
From: Vladimir Prus (ghost_at_[hidden])
Date: 2007-08-15 13:45:23
Christian Henning wrote:
> Hi there, a while ago I was asking some questions about the short
> option feature. If I'm not mistaken a short option can only be one
> letter long. Is that correct to say?
Yes.
> In my project I need more than this. So I started to just add the
> short names to the options list like I would do for all options. But
> in this case they would share the same variable. Like this:
>
> po::options_description settings( "" );
> settings.add_options()
> ( "input_1"
> , po::value< string >( &_input )
> ->default_value( "" )
> , "" )
> ( "i1"
> , po::value< string >( &_input )
> ->default_value( "" )
> , "" );
>
>
> Both options are pointing to the same variable. For some reasons this
> code works only for "input_1" and not for "i1". Why is that? If I use
> --i1="Hallo" the _input is empty.
Well, you specify default value for both options. So,
at the end of processing, both options have values, and both values
are assigned to 'input', in no particular order. Does this answer your
question?
- Volodya
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net