I too have just started to use it and can see many applications (it is very
kewl) - I have one quick question:
I am using the "boost::multi_index::sequenced<>" to index my list and would
like the ability to get the actual numeric number for the index (I am using
to store the zorder for a list of renderers) at the moment I do the
following:
UniqueIDIndex & index = m_pos.get<1>(); //Index on UniqueID
UniqueIDIndex::iterator it1 = index.find(id); //Fast get based on
UniqueID
GraphItemRendererContainer::iterator it2 = m_pos.project<0>(it1); //Get
"Index" index
return std::distance(m_pos.begin(), it2); //Calculate actual position in
index
Is there any "better" way?
Thx,
Gordon.
"Joaquin M Lopez Munoz"
Hi,
I am using the Boost MultiIndex container in conjunction with the
I encountered an runtime exception during some tests of my application. I made the mistake, that I tried to construct an index as a separate object instead of using a reference to the respective index.
The MultiIndex documentation highlights this issue:
"Note that get returns a reference to the index, and not an index object. Indices cannot be constructed as separate objects from the container they belong to, so the following
// Wrong: we forgot the & after employee_set::nth_index<1>::type const employee_set::nth_index<1>::type name_index=es.get<1>();
does not compile, since it is trying to construct the index object name_index. This is a common source of errors in user code."
I could reproduce the exception by using the MultiIndex example basic.cpp from the Boost 1.32.0 release. Unfortunately, Microsoft Visual C++ 7.1 compiles the above mentioned
Microsoft Visual C++ 7.1 compiler. line without an error
or warning.
Hi Jochen, In conformant compilers, index constructors are protected and the error shows at compile time (try with GCC if you have it handy.) Unfortunately, these constructors have to be made public on those compilers for which the defect macro BOOST_NO_MEMBER_TEMPLATE_FRIENDS is set: this includes all of the MSVC familiy, even the 8.0 version :( Other than that, have you experienced any difficulty, problem, do you have any suggestion for improvement? Users' feeback is much appreciated. Regards, Joaquín M López Muñoz Telefónica, Investigación y Desarrollo