Ticket #29394: t.cpp

File t.cpp, 718 bytes (added by christophe.prudhomme@…, 14 years ago)

test program to reproduce the crash

Line 
1#include <iostream>
2
3#include <boost/program_options.hpp>
4namespace po = boost::program_options;
5int main(int ac, char** av)
6{
7        using namespace std;
8//locale::global(locale(""));
9// Declare the supported options.
10po::options_description desc("Allowed options");
11desc.add_options()
12    ("help", "produce help message")
13    ("compression", po::value<int>(), "set compression level")
14;
15
16po::variables_map vm;
17po::store(po::parse_command_line(ac, av, desc), vm);
18po::notify(vm);
19
20if (vm.count("help")) {
21        cout << desc << "\n";
22    return 1;
23}
24
25if (vm.count("compression")) {
26    cout << "Compression level was set to "
27 << vm["compression"].as<int>() << ".\n";
28} else {
29    cout << "Compression level was not set.\n";
30}
31}