使用提升精神解析的大型结构

Large structures parsed using boost-spirit

本文关键字:大型 结构      更新时间:2023-10-16

我可以编译此页面上的员工示例代码。

如果我用另外 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根据上限有条件地包括预处理的源。