
Well, I think I've realised what happed there:
RecordsBySetting bySetting = records_.get<Record::setting>();
The index is copied there, and the copy is in invalid state for some reason. However, if take the reference, everything goes well: RecordsBySetting &bySetting = records_.get<Record::setting>(); 2008/7/7, Igor R <boost.lists@gmail.com>:
Hello,
I've got a multi_index_container with few indices, as follows:
struct Record { // some data };
typedef mi::multi_index_container< Record, mi::indexed_by< mi::ordered_non_unique<mi::tag<Record::stream>, mi::member<Record, int, &Record::streamID_> >, mi::ordered_non_unique<mi::tag<Record::setting>, mi::member<Record, int, &Record::settingID_> >
Records;
typedef Records::index<Record::stream>::type RecordsByStream; typedef Records::index<Record::setting>::type RecordsBySetting;
Records records_;
Then I insert 1 Record into records_. Later in the code I do the following lookup:
RecordsBySetting bySetting = records_.get<Record::setting>(); std::pair<RecordsBySetting::iterator, RecordsBySetting::iterator> sameSetting = bySetting.equal_range(1); // record with setting id == 1 exists in the container!