|
Boost Users : |
From: Gordon Smith (schmoo2k_at_[hidden])
Date: 2005-02-17 09:00:10
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" <joaquin_at_[hidden]> wrote in message
news:loom.20050217T115101-159_at_post.gmane.org...
Jochen Hammann <jochen.hammann <at> realtech.com> writes:
>
> Hi,
>
> I am using the Boost MultiIndex container in conjunction with the
Microsoft
Visual C++ 7.1 compiler.
> 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
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
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