c++ - 使用 boost-spirit 解析的大型结构

标签 c++ boost-spirit

我可以编译在 this page 上找到的员工示例代码.

如果我像这样用另外 8 个字符串扩展结构:

struct employee
{
    int age;
    std::string surname;
    std::string forename;
    std::string a1;
    std::string a2;
    std::string a3;
    std::string a4;
    std::string a5;
    std::string a6;
    std::string a7;
    std::string a8;
    double salary;
};

(当然我也扩展了 BOOST_FUSION_ADAPT_STRUCT 和语法),然后在我尝试编译时出现以下错误:

../include/boost/fusion/container/vector/convert.hpp:26:13: error: invalid use of incomplete type ‘struct boost::fusion::detail::as_vector<12>’
../include/boost/fusion/container/vector/detail/as_vector.hpp:26:12: error: declaration of ‘struct boost::fusion::detail::as_vector<12>’

我发现如果我的结构有 > 10 个项目,就会发生这种情况。两个问题:

  1. 为什么有这个限制?
  2. 我该如何解决?

欢迎任何输入。

最佳答案

FUSION_MAX_VECTOR_SIZE 定义为您想要的任何上限,查看 boost/fusion/container/vector/limits.hpp 中的默认定义。 boost/fusion/container/vector.hpp然后根据上限有条件地包含预处理源。

关于c++ - 使用 boost-spirit 解析的大型结构,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10515834/

相关文章:

c++ - CMake add_definitions 不局限于当前目录

c++ - 使用 boost::spirit 时无法转换 boost::variant 中的 boost::fusion 结构

c++ - 使用语义操作填充嵌套结构

C++ : Access of a child member from a parent class

c++ - 在指向 POD 类型的指针之间静态转换与重新解释转换

c++ - 比较bcrypt加密后的密码

c++ - 更改凹槽背景时隐藏 QSlider handle

c++ - 使用boost精神qi处理gor解析bnf语法的多行规则

c++ - 如何在语义操作中访问元组的元素

c++ - boost::spirit::qi 和乱序变量