Boost logo

Boost Users :

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


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!

In the last line, in equal_range() I've got an exception (access violation).

Am I doing something wrong?
Any help would be greatly appreciated!

Some tracing:
The crash is in ordered_index::equal_range(const CompatibleKey& x) in
its 1st line:
std::pair<node_type*,node_type*> p=
    ordered_index_equal_range(root(),header(),key,x,comp);
An attepmt to access the root() fails.

Here is the call stack:
SomeProg.exe!boost::multi_index::detail::ordered_index_node_compressed_base<std::allocator<void>
>::parent_ref::operator
boost::multi_index::detail::ordered_index_node_impl<std::allocator<void>
> *() Line 161 + 0x5 bytes C++
SomeProg.exe!boost::multi_index::detail::ordered_index<boost::multi_index::member<Record,int,8>,std::less<int>,boost::multi_index::detail::nth_layer<2,Record,boost::multi_index::indexed_by<boost::multi_index::ordered_non_unique<boost::multi_index::tag<Record::streamable,boost::mpl::na,boost::mpl::na,boost::mpl::na,boost::mpl::na,boost::mpl::na,boost::mpl::na,boost::mpl::na,boost::mpl::na,boost::mpl::na,boost::mpl::na,boost::mpl::na,boost::mpl::na,boost::mpl::na,boost::mpl::na,boost::mpl::na,boost::mpl::na,boost::mpl::na,boost::mpl::na,boost::mpl::na>,boost::multi_index::member<Record,int,4>,boost::mpl::na>,boost::multi_index::ordered_non_unique<boost::multi_index::tag<Record::setting,boost::mpl::na,boost::mpl::na,boost::mpl::na,boost::mpl::na,boost::mpl::na,boost::mpl::na,boost::mpl::na,boost::mpl::na,boost::mpl::na,boost::mpl::na,boost::mpl::na,boost::mpl::na,boost::mpl::na,boost::mpl::na,boost::mpl::na,boost::mpl::na,boost::mpl::na,boost::mpl::na,boost::mpl::na>,boost::multi_index::member<Record,int,8>,boost::mpl::na>,boost::mpl::na,boost::mpl::na,boost::mpl::na,boost::mpl::na,boost::mpl::na,boost::mpl::na,boost::mpl::na,boost::mpl::na,boost::mpl::na,boost::mpl::na,boost::mpl::na,boost::mpl::na,boost::mpl::na,boost::mpl::na,boost::mpl::na,boost::mpl::na,boost::mpl::na,boost::mpl::na>,std::allocator<Record>
>,boost::mpl::vector1<Record::setting>,boost::multi_index::detail::ordered_non_unique_tag>::root()
 Line 879 + 0x40 bytes C++
SomeProg.exe!boost::multi_index::detail::ordered_index<boost::multi_index::member<Record,int,8>,std::less<int>,boost::multi_index::detail::nth_layer<2,Record,boost::multi_index::indexed_by<boost::multi_index::ordered_non_unique<boost::multi_index::tag<Record::streamable,boost::mpl::na,boost::mpl::na,boost::mpl::na,boost::mpl::na,boost::mpl::na,boost::mpl::na,boost::mpl::na,boost::mpl::na,boost::mpl::na,boost::mpl::na,boost::mpl::na,boost::mpl::na,boost::mpl::na,boost::mpl::na,boost::mpl::na,boost::mpl::na,boost::mpl::na,boost::mpl::na,boost::mpl::na>,boost::multi_index::member<Record,int,4>,boost::mpl::na>,boost::multi_index::ordered_non_unique<boost::multi_index::tag<Record::setting,boost::mpl::na,boost::mpl::na,boost::mpl::na,boost::mpl::na,boost::mpl::na,boost::mpl::na,boost::mpl::na,boost::mpl::na,boost::mpl::na,boost::mpl::na,boost::mpl::na,boost::mpl::na,boost::mpl::na,boost::mpl::na,boost::mpl::na,boost::mpl::na,boost::mpl::na,boost::mpl::na,boost::mpl::na>,boost::multi_index::member<Record,int,8>,boost::mpl::na>,boost::mpl::na,boost::mpl::na,boost::mpl::na,boost::mpl::na,boost::mpl::na,boost::mpl::na,boost::mpl::na,boost::mpl::na,boost::mpl::na,boost::mpl::na,boost::mpl::na,boost::mpl::na,boost::mpl::na,boost::mpl::na,boost::mpl::na,boost::mpl::na,boost::mpl::na,boost::mpl::na>,std::allocator<Record>
>,boost::mpl::vector1<Record::setting>,boost::multi_index::detail::ordered_non_unique_tag>::equal_range<int>(const
int & x=1) Line 493 + 0x20 bytes C++


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