Boost logo

Boost Users :

Subject: Re: [Boost-users] [MultiIndex] how to rebuild index
From: JOAQUIN M. LOPEZ MUÑOZ (joaquin_at_[hidden])
Date: 2012-02-23 13:29:49


-----Mensaje original-----
De: boost-users-bounces_at_[hidden] [mailto:boost-users-bounces_at_[hidden]]
En nombre de Igor R
Enviado el: jueves, 23 de febrero de 2012 12:02
Para: boost-users_at_[hidden]
Asunto: [Boost-users] [MultiIndex] how to rebuild index

> Hello,
>
> What's the most simple way to rebuild an index? If elements change
> without notifying the container, would iterating from begin to end and
> calling modify() with no-op - do the job?
> (I remember there already was such a question, but can't find it.)

Hi Igor,

Briefly put, there is no way to do that. The only thing that will
work, though it's not officially guaranteed by the implementation, is:

* Modify ONE element without using replace() or modify() (by using a
const_cast, basically.)
* Before doing anything else with the container (except possibly
accessing their elements through previously existing iterators and/or
advance those iterators around), use modify() with a no-op functor,
as you suggest.

But you just can't externally (with const_cast) modify a bunch
of elements and then get the index to rebuild --the rebuilding machinery
assumes that at most one element (the one you call modify() on) is out
of place, so if other elements are shuffled as well you'll get
some sort of undefined behavior: core dump, whatever.

Joaquín M López Muñoz
Telefónica Digital

Este mensaje se dirige exclusivamente a su destinatario. Puede consultar nuestra política de envío y recepción de correo electrónico en el enlace situado más abajo.
This message is intended exclusively for its addressee. We only send and receive email on the basis of the terms set out at
http://www.tid.es/ES/PAGINAS/disclaimer.aspx


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