c++ - boost::multi_index_container 编译错误由于索引 typedef 上的类型不完整

标签 c++ boost boost-multi-array boost-multi-index

我正在使用 boost::multi_index_container(如下所示)并且在尝试对索引进行 typedef 时遇到编译错误:

struct del_t
{
  string del_id;
  string dev_version;
};

struct count_container_t
{
  uint32_t count_1;
  uint32_t count_2;
};

struct mic_t
{
  del_t d;
  uint32_t p;
  string c;
  map<uint32_t, count_container_t> b;
};

typedef multi_index_container
<mic_t,

 indexed_by
 <ordered_unique<member<mic_t,
                        del_t,
                        &mic_t::d>
                 >
  >
 > super_mic_t;

//The following line is causing the compile error. Compiles fine without it.
typedef super_mic_t::nth_index<0>::type zeroth_index_t; 

错误详情:

/usr/include/boost/multi_index/detail/base_type.hpp:54: error: invalid use 
of incomplete type 'struct 
boost::multi_index::ordered_unique<boost::multi_index::member<mic_t, 
del_t, &mic_t::d>, mpl_::na, mpl_::na>'

尝试使用 typenametemplate 的变体,但我想我做的不对(因为我没有正确理解问题,无法解决它正确)。

如有任何帮助,我们将不胜感激。

谢谢。

PS:我使用的是“g++ (GCC) 4.2.4 (Ubuntu 4.2.4-1ubuntu4)”和“boost-1.42”。

最佳答案

看起来您可能缺少所需的包含,可能是 ordered_unique::nth_index

关于c++ - boost::multi_index_container 编译错误由于索引 typedef 上的类型不完整,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5195035/

相关文章:

关于 unordered_map 的 C++ 结构化绑定(bind)问题

c++ - Boost 二进制序列化有时不起作用。解析的数据有时会损坏

c++ - 为什么 `boost::multi_array_ref` 的析构函数是非虚拟的?

c++ - 取消引用指向容器类成员的指针

c++ - Qt延迟处理mousePressEvent

c++ - 从语言设计层面来看,为什么在编译时无法推导出条件时, "if constexpr"不会衰减为 "trival if"

c++ - boost::shared_ptr 销毁回调

c++ - 我能知道转换中匹配 boost::proto::_ 的类型吗?

c++ - 如何将 Boost.MultiArray 的二维 View 作为函数的参数?

c++ - 调整 boost::multi_array 的大小以匹配另一个