|
Boost : |
From: Neal D. Becker (ndbecker2_at_[hidden])
Date: 2004-03-26 15:27:45
There is a bug in program_options. Now I remember, this is why I stopped
using it before.
It can't accept negative numbers as command line arguments!
#include <boost/program_options.hpp>
#include <iostream>
#include <cxxabi.h> // demangle
using namespace std;
namespace po = boost::program_options;
int main (int argc, char** argv) {
double angle;
std::set_terminate(__gnu_cxx::__verbose_terminate_handler);
po::options_description desc("Allowed options");
desc.add_options()
("help", "produce help message")
("angle,a", po::value (&angle))
;
po::variables_map vm;
po::store(po::parse_command_line(argc, argv, desc), vm);
po::notify(vm);
if (vm.count("help")) {
cout << desc << "\n";
return 1;
}
cout << "angle: " << angle << '\n';
}
./Test1 -a -0.2
terminate called after throwing a
`boost::program_options::invalid_command_line_syntax'
what(): required parameter is missing in '-a'
Aborted
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk