我正在使用 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>'
尝试使用 typename
和 template
的变体,但我想我做的不对(因为我没有正确理解问题,无法解决它正确)。
如有任何帮助,我们将不胜感激。
谢谢。
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/