gpt4 book ai didi

c++ - Boost Spirit 字符解析器

转载 作者:行者123 更新时间:2023-11-30 04:29:20 25 4
gpt4 key购买 nike

这是一个代码示例:

// file main.cpp

#include <iostream>
#include <boost/tuple/tuple.hpp>
#include <boost/tuple/tuple_io.hpp>
#include <boost/spirit/include/qi.hpp>

int main()
{
std::string s( "1 A" );
boost::tuple<double, char> p;
complex_matrix_parser::iterator b = s.begin();
complex_matrix_parser::iterator e = s.end();
qi::phrase_parse( b, e,
( qi::double_ >> qi::char_('A') ),
qi::space, qi::skip_flag::postskip, p );

std::cerr << "==== " << p << std::endl;

return 0;
}

这应该打印 ==== (1 A) 对吗?但它会打印 ==== (1 ),因此会跳过 'A' 字符。

我在这里做错了什么?

最佳答案

使用 boost::fusion::vector 而不是 boost::tuple 一切都会正常。

关于c++ - Boost Spirit 字符解析器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9448120/

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