Boost logo

Boost Users :

Subject: Re: [Boost-users] [Multi Index] Random Access Index C2247 Compile Error
From: Igor R (boost.lists_at_[hidden])
Date: 2012-07-09 07:47:16


> Igor, thanks for getting back to me. Very good suggestion.
>
> I was trying to gain 'direct random access' to the items in the container by using the bracket operator on the MIC object, as you would do on a vector... "m_micOrders[index]".
>
> This is how example 10 in the Boost documentation shows the usage, using a text block stored in a MIC called tc, and using tc[pos] to access the pos'th element.
>
> After a review of the MIC source code and a bit of thinking, I have tried first getting a reference to the random access index, and then using the bracket operator on the reference to the index like this (where the random index is the seventh defined index in my case)...
>
> OrderMIC::nth_index<6>::type& index6 = m_micOrders.get<6>();
> spOrder = index6[ index ];
>
> It seems a general rule with MIC's is that you should never call any member functions on anything other than a reference to one of the indices.

Applying an accessor on the MIC itself means applying it on its 1st
index (its kindof "default" index).


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