Boost logo

Boost Users :

From: JOAQUIN M. LOPEZ MUÑOZ (joaquin_at_[hidden])
Date: 2008-07-07 14:02:27

De: boost-users-bounces_at_[hidden] [boost-users-bounces_at_[hidden]] En nombre de Igor R [boost.lists_at_[hidden]]
Enviado el: lunes, 07 de julio de 2008 16:53
Para: boost-users_at_[hidden]
Asunto: Re: [Boost-users] [boost-users][Multi-Index] crash in equal_range()

> Well, I think I've realised what happed there:
> RecordsBySetting bySetting = records_.get<Record::setting>();
> The index is copied there, and the copy is in invalid state for some
> reason. However, if take the reference, everything goes well:
> RecordsBySetting &bySetting = records_.get<Record::setting>();

Hi Igor,

Correct, the problem was exactly as you said: indices are not meant to be
copied and can only be referred to to via references (or pointers). You
might legitimately ask: why haven't you made their copy ctors
private/protected so as to avoid this kind of errors? Well, the copy ctors
are indeed protecetd except for those *defective* compilers for which the
is set, among which are MSVC 8.0 and older (which I guess include the
one you're using).

This issue gets reported every so often, see for instance an older post
about it:

To try to prevent new users from keep falling into the same trap I added
some warning text at the last paragraph of

Unfortunately, the caveat seems not to be conspicuous enough, judging from
the number of times this problem has been reported. I'm sorry it also hit
you, hope your further experience with B.MI is more pleasant.

Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at