|
Boost : |
From: Neal Becker (ndbecker2_at_[hidden])
Date: 2004-03-25 22:04:01
OK, I found the answer to my (stupid) question --- I had to relearn how to
use program_options.
Which brings us to a IMHO really cool little example, combining lambda with
program_options:
,----[ /home/nbecker/boost-program_options/Test1.cc ]
| #include <boost/program_options.hpp>
| #include <iostream>
| #include <cxxabi.h> // demangle
| #include <cmath>
|
| using namespace std;
| namespace po = boost::program_options;
|
| #include <boost/lambda/lambda.hpp>
| using namespace boost::lambda;
|
| 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", po::value<double>()->notifier(var(angle)=180./M_PI*_1), "set
| 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';
| }
`----
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk