【发布时间】:2014-01-07 21:54:00
【问题描述】:
我有一个 boost multi_index_container 存储一堆具有以下索引的位置
boost::multi_index::indexed_by<
boost::multi_index::ordered_unique<
boost::multi_index::tag<Slot>,
boost::multi_index::identity<SlotData>
>, //ordered_unique
boost::multi_index::ordered_non_unique<
boost::multi_index::tag<Level>,
SlotData::ExtractZ
>, // ordered_non_unique
...//index by
.//typedef as SlotLocations
在这个定义中,我相信默认索引将是基于ordered_unique 的Slot。稍后我有一个迭代器SlotLocations::iterator,我想用它来存储基于Level(即ordered_non_unique)的搜索结果:
typedef SlotLocations::index<Level>::iterator MIterator;
std::pair<MIterator, MIterator> range = map.get<Level>().range(..some conds..);
SlotLocations::iterator itr = range.first; //error
范围搜索有效并返回存储在range 中的所需结果,但是此代码无法编译,带有标记的行会出现以下错误:
error: no match for 'operator='
为什么我不能像这样分配/存储迭代器?以及存储搜索结果迭代器的可能方式是什么?
【问题讨论】:
标签: c++ boost multi-index