Boost logo

Boost Users :

Subject: Re: [Boost-users] program_options
From: Eric J. Holtman (eric_at_[hidden])
Date: 2009-11-28 11:47:48


Dejan wrote:
> Hi all,
>
> I'm experimenting with program_options and trying to get something like
> "mandatory options". E.g.
>
> # my_prog -a someValue
>
> with "-a someValue" as mandatory options. Can I define "something" with
> program_options.
>
>

Try reading the documentation. The first example in
the tutorial does exactly that:

if (vm.count("compression")) {
    cout << "Compression level was set to "
 << vm["compression"].as<int>() << ".\n";
} else {
    cout << "Compression level was not set.\n";
}

That's the "else" part of the test.


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