我可以编译在 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 个项目,就会发生这种情况。两个问题:
- 为什么有这个限制?
- 我该如何解决?
欢迎任何输入。
最佳答案
将 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/