Boost Spirit自动分析器在一个双元组中失败
Boost Spirit Auto Parser fails for a tuple of doubles
在下面的代码中,我试图使用Boost Spirit Auto Parser来处理一个或两个双精度序列,但它无法编译。我在这里做错了什么?
// file main.cpp
#include <boost/tuple/tuple.hpp>
#include <boost/spirit/include/qi.hpp>
namespace qi = boost::spirit::qi;
int main()
{
boost::tuple<double, double> p;
char* i = 0;
qi::phrase_parse( i, i, p, qi::space );
// qi::phrase_parse( i, i, qi::double_ >> qi::double_, qi::space, qi::skip_flag::postskip, p );
return 0;
}
注释掉的行进行编译,因此它接受boost::tuple<double, double>
作为qi::double_ >> qi::double_
的属性类型;但是它无法从属性类型中获得解析器。为什么?
这与您的另一个问题中的答案相同-请使用boost::fusion::vector
。
如果我在你的程序中添加以下include,它会为我编译(g++4.6.1/boost 1.46.1):
#include <boost/fusion/adapted/boost_tuple.hpp>
我相信这将boost::tuple调整为符合boost::fusion序列,由sequence复合属性规则要求:
http://www.boost.org/doc/libs/1_48_0/libs/spirit/doc/html/spirit/qi/quick_reference/compound_attribute_rules.html
Graham
相关文章:
- 在boost::hana中给定一个键元组,如何从映射中获取值元组
- 从 c++ 中的字符串向量创建一个元组
- 用一个额外的元素扩展 std::array 的每个 std::元组
- 我在代码中收到一个运行时错误,该错误如何通过修改最多一个元素来查找数组是否可以变得不减少
- 使用对另一个元组不同类型的元素的非常量引用来初始化元组的元素
- 您可以static_assert一个元组只有一种满足特定条件的类型
- 使用参数包和元组创建一个简单的表达式类
- 如何将多个可变参数模板元组类组合成一个类?
- 我如何打印一个元组矢量
- 初始化boost :: hana ::元组用一个参数
- 如何创建一个 std::tuple,其中包含由索引元组指定的向量中的成员
- c++存储映射元组的引用,以便在另一个函数中使用
- 接受元组并返回另一个元组的功能
- 通过在上一个数组结束后立即存储下一个元素来扩展数组
- 做一个CPP分类的元组
- 用另一个元组中的元素填充一个元组
- 我正在使用可变参数模板在 C++11 中创建一个元组类。如何使用其实例变量?
- 创建一个元组样式的类来优化未使用的部分
- 如何剥离一个元组<>回到可变类型模板列表
- 段故障返回一个元组