Boost logo

Boost Users :

From: Merrill Cornish (merrill.cornish_at_[hidden])
Date: 2005-11-03 10:30:42


I am trying to use the Boost 1.32.0 program_options library for the first time with MGWin. Since what I need is identical to what is in the Getting Started section of the program_options Tutorial, I copied that. Here is the code from the tutorial:

    po::options_description desc("Allowed options");
    desc.add_options()
        ("help", "produce help message")
        ("compression", po::value<int>(), "set compression level")
    ;

    po::variables_map vm;
    po::store(po::parse_command_line(ac, av, desc), vm);
    po::notify(vm);

The problem occurs in the store() function. The compiler says it doesn't have a store() to match that call and suggests two possibilities.

Examining the .hpp files, it appears that the two argument version of store() defaults to using wchar_t, which doesn't seem right. So, I tried

    po::store(po::parse_command_line(ac, av, desc), vm, true);

to get UTF8 (simple char).

The next complaint is apparently about the parse_command_line() call as the first argument. If I pull parse_command_line() out into a separate assignment statement to an intermediate variable, then put its results into store(), that could/would work except there now seems to be a conflict between the template types of char versus const char. I can get the assignment of parse_command_line() to an intermediate result to compile, but store() fails because of mismatched type problems. Or, I can get store() to compile, but the assignment fails for mismatched type problems.

I apologize for not having the specific error messages here since the machine I'm compiling on is not available right now.

Merrill

P.S. About the Documentation: The program_options library document looks slick and very professional. Furthermore, it obviously took some time to create with all of the examples. However, I've never seen programming library documentation that didn't actually list the methods and functions in the library. As it is, if you are lucky, the method you need to mentioned, in passing, in an example. However, looking in the hpp and cpp files shows there is a lot more there.


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