Boost练习程序(program_options)

#include 
#include <string>
#include 

int main(int argc,char **argv)
{
    namespace po = boost::program_options;

    po::option_description desc("allowed options");

    desc.add_options()
        ("help,h",        "help message")
        ("version,v",    "display verison")
        ;

    po::variables_map vm;
    po::store(po::parse_command_line(argc,argv,desc),vm);
    po::notify(vm);

    if (vm.count("help"))
    {
        std::cout<std::endl;
        return 0;
    }

    if (vm.count("version"))
    {
        std::cout<<"version 0.0.1"<<std::endl;
        return 0;
    }

    std::cout<<"exec program"<<std::endl;
    return 0;

}

转载于:https://www.cnblogs.com/tiandsp/archive/2012/07/09/2582198.html

你可能感兴趣的:(Boost练习程序(program_options))