【问题标题】:Another boost error另一个提升错误
【发布时间】:2012-11-06 02:59:09
【问题描述】:

在这段代码中我得到了巨大的错误

static void ParseTheCommandLine(int argc, char *argv[])
{
int count;
int seqNumber;

namespace po = boost::program_options;

std::string appName = boost::filesystem::basename(argv[0]);

po::options_description desc("Generic options");
desc.add_options()
("version,v", "print version string")
("help", "produce help message")
("sequence-number", po::value<int>(&seqNumber)->default_value(0), "sequence number")
("pem-file", po::value< vector<string> >(), "pem file")
;

po::positional_options_description p;
p.add("pem-file", -1);

po::variables_map vm;
po::store(po::command_line_parser(argc, argv).
          options(desc).positional(p).run(), vm);
po::notify(vm);

if (vm.count("pem file"))
{
    cout << "Pem files are: "
         << vm["pem-file"].as< vector<string> >() << "\n";
}

cout << "Sequence number is " << seqNumber << "\n";

exit(1);

../../../FIXMarketDataCommandLineParameters/FIXMarketDataCommandLineParameters.hpp|98|错误:在 'std::operator&)(& std::cout)), ((const char*)"Pem 文件为:")) (((const char*)"pem-file"), ((const std::allocator& )((const std::allocator*)(& std::allocator()))))))))->boost::program_options::variable_value::as with T = std::vector, std::allocator >, std::allocator, std::allocator > > >'|

【问题讨论】:

  • 你真的应该出示vm的声明...
  • 可能是您从 cout(); 得到的类似错误
  • 欢迎来到 Stack Overflow。请记得提出问题

标签: c++ boost boost-program-options


【解决方案1】:

向量不实现ostream &amp; operator&lt;&lt;(std::ostream &amp;)

你应该这样做:

cout << "Pem files are: ";
for (auto & x : vm["pem-file"].as< vector<string> >())
    cout << x << "\n";

【讨论】:

猜你喜欢
  • 2020-12-19
  • 2015-10-24
  • 2015-04-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-01-21
相关资源
最近更新 更多