Boost logo

Boost Users :

From: Igor R (boost.lists_at_[hidden])
Date: 2008-07-07 10:53:52


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_at_[hidden]>:
> 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!


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net