0
我试图按照选项详细 sectionof的tutorial for the Boost Program Options library和我得到了以下错误:要调用`cout << std :: vector <_Ty>`包含哪个头?
error C2679: "binary '<<' : no operator found which takes a right-hand operand
of type 'const std::vector<_Ty>'" (or there is no acceptable conversion)
我的代码如下。我猜我需要包括一个标题,但我不知道哪一个。
#include <boost/program_options.hpp>
#include <iostream>
#include <vector>
#include <string>
using std::cout;
using std::endl;
using std::vector;
using std::string;
namespace po = boost::program_options;
int options_description(int ac, char* av[])
{
int opt;
po::options_description desc("Allowed options");
desc.add_options()
("help", "produce help message")
("optimization", po::value<int>(&opt)->default_value(10),
"optimization level")
("include-path,I", po::value< vector<string> >(), "include path")
("input-file", po::value< vector<string> >(), "input file")
;
po::positional_options_description p;
p.add("input-file", -1);
po::variables_map vm;
po::store(po::command_line_parser(ac, av).
options(desc).positional(p).run(), vm);
po::notify(vm);
if (vm.count("include-path"))
{
cout << "Include paths are: "
<< vm["include-path"].as< vector<string> >() << "\n"; // Error
}
if (vm.count("input-file"))
{
cout << "Input files are: "
<< vm["input-file"].as< vector<string> >() << "\n"; // Error
}
cout << "Optimization level is " << opt << "\n";
return 0;
}
int main(int argc, char *argv[])
{
return options_description(argc, argv);
}
你用来编译这段代码的确切命令是什么? – 2012-12-12 13:43:43
我正在使用Visual Studio 2010构建项目。我相信这些选项如下:'cl/c/ZI/nologo-/W3/WX-/Od/Oy-/D WIN32/D _DEBUG/D _CONSOLE/D _UNICODE/D UNICODE/Gm/EHsc/RTC1/MDd/GS/fp:precise/Zc:wchar_t/Zc:forScope/Fo“Debug \\”/Fd"Debug\vc100.pdb“/ Gd/TP/analyze-/errorReport:prompt main.cpp' –
您确定Visual Studio知道在哪里寻找boost库(参见[this](http://www.boost.org/doc/libs/1_52_0/more/getting_started/windows.html#build-from-the-visual-studio-ide) )详情) – 2012-12-12 14:00:29