Boost logo

Boost Users :

Subject: Re: [Boost-users] [multi_index] are indices in a random access index stable on addition, can we have an
From: Joaquin M LópezMuñoz (joaquin_at_[hidden])
Date: 2015-06-27 05:34:00


Nick Stokes <randomaccessiterator <at> gmail.com> writes:

> I have a stream of pairs of elements of type T,  and want to insert
> individual T's uniquely into a container and convert the pairs to a
> pair of indices into this container [...]
>
> typedef bmi::multi_index_container< T, bmi::indexed_by
>    < bmi::hashed_unique< bmi::identity<T> >
>    ,  bmi::random_access<>
>    >> MIC;
>
> [...]
>
> auto index_of = [&]( MIC::const_iterator i ) { 
>    return elements.project<1>(i) - elements.get<1>().begin();
> }
>
> So my questions are
>
> (1)  Is the implementation of index_of() correct?
> (or better, is there something like this already for random
> access indices)

This is correct and gives you the *insertion* order, if this is
indeed¡…Ёå½ÔÉ”¥¹Ñ•É•ÍÑ•¥¸¸€((ø€ È¤%́ѡ”Ý…äÑ¡•ä…É”ÕÍ•¥¸…‰½Ù”±½½ÀÍÑ…‰±”°Ý¡•É”•±•µ•¹ÑÌ(ø…É”¥¹Í•ÉÑ•…™Ñ•È…¸¥¹‘•à¥Ì½‰Ñ…¥¹•ü()%Ё¥ÌÍÑ…‰±”…́±½¹œ…́å½Ô‘½¸Ð•É…Í”•±•µ•¹Ñ̸()!Q ())½…Å×µ¸43ÍÁ•è5׎è)Q•±•›͹¥


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