【发布时间】:2012-03-13 20:48:17
【问题描述】:
这是我想写的代码。
int opt;
po::options_description desc("Allowed options");
desc.add_options()
("help","produce help message")
("compression",po::value<int>(&opt)->default_value(10),"optimization level")
("include-path,I", po::value< std::vector<std::string> >(), "include path")
("input file", po::value< std::vector<std::string> >(),"input file")
;
po::variables_map vm;
po::store(po::parse_command_line(argc,argv,desc),vm);
po::notify(vm);
if (vm.count("help")){
std::cout <<desc<<"\n";
return 1;
}
if (vm.count("compression")){
std::cout<<"Compression level was set to"<<vm["compression"].as<int>()<<".\n";
} else {
std::cout << "compression level was not set.\n";
}
if (vm.count("include-path")){
std::cout << "Include paths are: " << vm["include-path"].as< std::vector<std::string> > ()<< "\n";
}
编译器对我要打印 include-path 参数的最终 if 语句给出错误。它给出的错误是
rx_timed_samples.cpp:62:96: 错误:'std::operator(const std::allocator)(& std::allocator()))))))->boost::program_options::variable_value:: 与 T = std ::vector, std::allocator > >'
我不明白?请帮忙。
【问题讨论】: