【发布时间】:2012-08-10 10:11:27
【问题描述】:
我确实想在代码中的注释中为位置参数提供默认值,但编译器会抱怨。代码编译得很好。我使用 boost 1.46.1 和 g++
int main(int argc, char *argv[]) {
namespace po = boost::program_options;
po::positional_options_description p;
p.add("path", -1);
po::options_description desc("Options");
std::vector<std::string> vec_str;
std::string str;
desc.add_options()
("foo,f", po::value< std::string >()->default_value(str), "bar")
//("path,p", po::value< std::vector<std::string> >()->default_value(vec_str), "input files.")
("path,p", po::value< std::vector<std::string> >(), "input files.")
;
po::variables_map vm;
po::store(po::command_line_parser(argc, argv).options(desc).positional(p).run(), vm);
po::notify(vm);
}
【问题讨论】:
-
这一行编译:
("path,p", po::value >()->default_value(std::vector(), ""), "input files.")
但我不知道为什么
标签: c++ boost boost-program-options