gpt4 book ai didi

c++ - 另一个 boost 错误

转载 作者:行者123 更新时间:2023-11-30 02:58:49 26 4
gpt4 key购买 nike

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

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<< [with _Traits = std::char_traits]((( std::basic_ostream >&)(& std::cout)), ((const char*)"Pem 文件是:")) << ((const boost::program_options::variable_value*)vm.boost::program_options::variables_map::operator[](((const std::string&)(& std::basic_string, std::allocator >(((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 >> >'|

最佳答案

vector 不实现 ostream & operator<<(std::ostream &) .

你可能应该这样做:

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

关于c++ - 另一个 boost 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13432616/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com