【发布时间】:2021-06-24 16:30:16
【问题描述】:
是否可以对 boost::multi_index_container 中的键和元素使用不同类型的数据结构? GCC 让我编译这样的东西:
struct StructA {
std::string name;
};
struct StructB {
int primary;
int secondary;
};
using mic =
multi_index_container<
StructA,
indexed_by<
composite_key<
StructB,
member< StructB, int, StructB::primary >,
member< StructB, int, StructB::secondary >
>>>;
首先,我不确定上面的代码是否违反了任何类型的 multi_index_container 用法。它当然可以使用不同的元素 (StructA) 和复合索引键 (StructB) 进行编译。其次,我如何插入/放置到这样的容器中?三、如何访问这样一个容器中的元素?
【问题讨论】:
标签: c++ boost-multi-index